bhs67
bhs67

Reputation: 83

OleDbCommand, WHERE

With an Access table (CustomersTable) and two fields (CustomerID, CustomerName) ... field#1 is number, field#2 is text:

command.CommandText = "SELECT CompanyName FROM CustomersTable WHERE CompanyName 'Zap'";
command.ExecuteReader();

results in error (missing operator) in query expression 'CompanyName 'Zap''.

command.CommandText = "SELECT CompanyName FROM CustomersTable WHERE CompanyName VALUES(?)";
command.Parameters.Add("@p1", OleDbType.VarChar).Value = "Zap";
command.ExecuteReader();

results in error (missing operator) in query expression 'CompanyName VALUES(?).

I suspect ExecuteReader() may be incorrect.

Upvotes: 0

Views: 707

Answers (1)

Rahul Singh
Rahul Singh

Reputation: 21795

You are missing = sign.

command.CommandText = "SELECT CompanyName FROM CustomersTable WHERE CompanyName =  @p1";

Upvotes: 3

Related Questions