請讓我知道如何插入兩個變量。它不直接給我的用戶名和移動中的代碼一樣我的C#代碼插入在mysql中的問題
string insert [email protected]"Insert into userHistory(userid,mobile) values(x,y)";
一個問題這是我的代碼,但它未能插入(編者注:OP提供錯誤)
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));
「我無法做到」並不真正描述問題。見http://tinyurl.com/so-hints –
什麼是錯誤? –
嘿@Pranay Rana,我認爲你的'?'-key卡住了;-) –