Jako PH
asked on
C++ MySql Getting count ids and + 1
Hi, i wish if everyone is having a good day.
However i have an problem in mysql i would like to get the count of ids column in my table and plus 1 to the number how ever when i do like that it types +1 as string for example the result of counting was 3 it will add 3 to 1 like this 31 not 3+1=4 so i don't know how to solve this here's my code :
However i have an problem in mysql i would like to get the count of ids column in my table and plus 1 to the number how ever when i do like that it types +1 as string for example the result of counting was 3 it will add 3 to 1 like this 31 not 3+1=4 so i don't know how to solve this here's my code :
String^ constring = L"datasource=...;port=...;username=...;password=..."; // Giving informations to the server
MySqlConnection^ conDataBase = gcnew MySqlConnection(constring);
MySqlCommand ^GetCount = gcnew MySqlCommand("Select Count(ID) from newdatabase.my_table;", conDataBase);
MySqlDataReader^ myReader;
MySqlCommand ^cmdDataBase;
try {
conDataBase->Open();
myReader = GetCount->ExecuteReader();
while (myReader->Read()) {
int Got = myReader->GetInt32(0);
cmdDataBase = gcnew MySqlCommand("Insert into newdatabase.my_table (ID) Values ('" + Got+1 + "');", conDataBase);//queries
}
myReader->Close();
myReader = cmdDataBase->ExecuteReader();
}
catch (Exception ^Ex) {
MessageBox::Show(Ex->Message);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.