使用Access表(CustomersTable)和两个字段(CustomerID,CustomerName)...字段#1是数字,字段#2是文本:
command.CommandText = "SELECT CompanyName FROM CustomersTable WHERE CompanyName 'Zap'";
command.ExecuteReader();
在查询表达式' CompanyName' Zap'
中导致错误(缺少运算符)。command.CommandText = "SELECT CompanyName FROM CustomersTable WHERE CompanyName VALUES(?)";
command.Parameters.Add("@p1", OleDbType.VarChar).Value = "Zap";
command.ExecuteReader();
在查询表达式' CompanyName VALUES(?)中导致错误(缺少运算符)。
我怀疑ExecuteReader()可能不正确。
答案 0 :(得分:3)
您缺少=
标志。
command.CommandText = "SELECT CompanyName FROM CustomersTable WHERE CompanyName = @p1";