错误42000必须声明标量变量“@ID”

时间:2015-09-22 05:45:09

标签: c# asp.net .net ado.net ado

在sql查询中设置参数时出错

string cs = ConfigurationManager.ConnectionStrings["conString"].ConnectionString.ToString();
OdbcConnection con = new OdbcConnection(cs);


OdbcCommand cmd = new OdbcCommand("select CustomerID, LastName, FirstName from Customers.Customer.Customer_Details where CustomerID = @ID", con);
con.Open();
cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(txtID.Text));
OdbcDataReader reader = cmd.ExecuteReader();

0 个答案:

没有答案