i have a problem. So i have the problem, that the if-query is not working. he will always jump in the else-path. But in the database is a entry, so it isnt empty...
Jump:
string query = "SELECT * FROM `depositRequests` LIMIT 1";
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader reader = cmd.ExecuteReader();
Thread.Sleep(1000);
reader.Read();
Log.Info("Durchlauf: " + i);
if (reader.Read())
{
SteamID SteamAddID = new SteamID(reader.GetString(2));
string authCode = reader.GetString(3);
Log.Info("SteamAddID: " + SteamAddID);
Log.Info("AuthCode: " + authCode);
Bot.log.Success("Add SteamAddID: " + SteamAddID + "AuthCode: " + authCode);
AddFriendForTrade(SteamAddID, authCode);
}
else
{
Bot.log.Warn("No Data found! Waiting for Deposit Request");
Thread.Sleep(60000);
reader.Close();
i++;
goto Jump;
}
So why he always jump in the else-path although there is an entry in the database?
Thank you for your help!
Because you are getting only one record, then reading it before if
statement on this line:
Thread.Sleep(1000);
reader.Read(); <---
Since there is no second record,your second call to Read
always returns false .
You should remove this line and call Read
only once in your if
statement or store the result of Read
method and use that variable within the if
:
bool isRecordExists = reader.Read();
if(isRecordExists)
{
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.