Reputation: 83
With an Access table (CustomersTable) and two fields (CustomerID, CustomerName) ... field#2 contains "Zap":
command.CommandText = "SELECT CustomerID, CompanyName FROM CustomersTable WHERE CompanyName = @p1";
command.Parameters.Add("@p1", OleDbType.VarChar).Value = "Zap";
reader = command.ExecuteReader();
Works fine.
Changing the parameters value to "Za*" finds nothing. What is used for "don't care"?
Upvotes: 0
Views: 117
Reputation: 21795
Because "Zap" is not equal to "Za"
You nee to use Like
operator something like this:-
command.CommandText = "SELECT CustomerID, CompanyName FROM CustomersTable WHERE CompanyName LIKE @p1";
command.Parameters.Add("@p1", OleDbType.VarChar).Value = "%Za%";
Upvotes: 2
Reputation: 591
I believe you want to use a LIKE command:
SELECT CustomerID, CompanyName FROM CustomersTable WHERE CompanyName LIKE 'Za%'
Upvotes: 1