Reputation: 430
I'm using C# to select something from an Access (2003 or 2007 I believe) database but it is not selecting anything. I tried the SQL syntax in Access itself and it seems to work fine. I'm rather new to C# and Access.
What I have so far:
OleDbCommand command = new OleDbCommand("Select * from Lid Where Naam Like @naam order by RangID desc, Creatiedatum, Naam", connection);
command.Parameters.Add(new OleDbParameter("@naam", "*" + naam + "*"));
I tried some variations, using % instead of *, putting it on in the first line instead of at the parameter etc. But nothing seems to work so far. I didn't find a solution Googling, maybe I just don't know what to Google as like I said before, I'm pretty new to C# and Access.
Upvotes: 1
Views: 455
Reputation: 97131
With OleDb, you definitely need %
instead of *
as the wild card.
I don't know .Net, but I'm guessing this will work ...
OleDbCommand command = new OleDbCommand("Select * from Lid Where Naam Like '%' & @naam & '%' order by RangID desc, Creatiedatum, Naam", connection);
command.Parameters.Add(new OleDbParameter("@naam", naam));
Upvotes: 5