代码如下:
con.Open();
MySqlCommand oSqlCmd =con.CreateCommand();
oSqlCmd.CommandText = "update Word set spelling =@spelling where word_id =10000";
oSqlCmd.Parameters.Add("@spelling","abc");
oSqlCmd.ExecuteNonQuery();
con.Close();这样数据库更新的是空字符串 ,而不是“abc”如果代码改成这样:
 con.Open();
MySqlCommand oSqlCmd =con.CreateCommand();
oSqlCmd.CommandText = "update Word set spelling =? where word_id =10000";
oSqlCmd.Parameters.Add("@spelling","abc");
oSqlCmd.ExecuteNonQuery();
con.Close();
则提示错误:Parameter '?' must be defined如果代码改成这样:
con.Open();
MySqlCommand oSqlCmd =con.CreateCommand();
oSqlCmd.CommandText = "update Word set spelling =? where word_id =10000";
oSqlCmd.Parameters.Add("@spelling",MySqlDbType.VarChar,200);
oSqlCmd.Parameters["@spelling"].Value="abc";
oSqlCmd.ExecuteNonQuery();
con.Close();
提示错误:Parameter '@spelling' not found in collection
请各位大虾给出正确的代码