SqlCommand oCmd;
oCmd.Connection.Open();
oCmd.CommandText="update Customers set CompanyName=str2,ContactName=str3 where CustomerID='"+str1+"'";
oCmd.ExecuteNonQuery();
为何报错,无效的列名 str2,str3敬请各位大哥大姐帮帮小弟

解决方案 »

  1.   

    改成:
    oCmd.CommandText="update Customers set CompanyName='"+str2+"',ContactName='"+str3+"' where CustomerID='"+str1+"'";
      

  2.   

    "update Customers set CompanyName='"+str2+"',ContactName='"+str3+"' where CustomerID='"+str1+"'";
      

  3.   

    oCmd.CommandText="update Customers set CompanyName=str2,ContactName=str3 where CustomerID='"+str1+"'";
    改成
    oCmd.CommandText="update Customers set CompanyName="+str2+",ContactName="+str3+" where CustomerID="+str1;另外:SqlCommand oCmd;
    改成
    SqlCommand oCmd=new SqlCommand();