kindly let me know how to insert two variables. its not a problem giving directly my userid and mobile in the code like
string insert =@"Insert into userHistory(userid,mobile) values(x,y)";
This is my code, but it fails to insert (editors note: OP provided no error)
int userid = 123456;
long mobile = 91888888888;
sqlConn = new MySqlConnection(/* conn string removed */);
sqlConn.Open();
string insert =
@"Insert into userHistory(userid,mobile) values(@userid,@mobile);";
MySqlCommand cmd = new MySqlCommand(insert,sqlConn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new MySqlParameter("@userid", userid));
cmd.Parameters.Add(new MySqlParameter("@mobile", mobile));
Without more Information, I guess the type of your command should be “Text” and not CommandType.StoredProcedure, since you do not execute a SP. And you have to execute the command (maybe this is only missing in your code)