mysql参数化查询语句问题
部分代码如下:
using (MySqlConnection conn = new MySqlConnection(connectionString))
{
conn.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
MySqlTransaction ts = conn.BeginTransaction();
try
{
for (int i = 0; i < dt.Rows.Count; i++)
{
cmd.Parameters.AddWithValue("?PrimaryID",dt.Rows[i][1]);
cmd.CommandText = "select * from infomine_bulletin where PrimaryID=?PrimaryID";
object ob = cmd.ExecuteScalar();
返回的Ob为空,但我确实在infomine_bulletin表中能够查询到此条数据,console.writeline(cmd.Parameters["PrimaryID"].value)确实已经赋值,select语句失败
------解决方案-------------------- public int UpdateDishe(string dishUnitID, string dishNO, string dishNameCH, string dishNameEN, string py, string price, string cookingTime, string eatingTime, string inMenu, string UserID)
{
MySqlConnection conn = DBManager.GetConn();
try
{
string sql = "update dishes,dishunit set dishes.dishN