C# 在OleDbCommand中使用“…where Column like…”不起作用
我用C从Access 2003或2007数据库中选择了一些东西,但它没有选择任何东西。我在Access本身中尝试了SQL语法,它似乎工作得很好。我对C和Access比较陌生 到目前为止,我所拥有的:C# 在OleDbCommand中使用“…where Column like…”不起作用,c#,sql,visual-studio,ms-access,oledbcommand,C#,Sql,Visual Studio,Ms Access,Oledbcommand,我用C从Access 2003或2007数据库中选择了一些东西,但它没有选择任何东西。我在Access本身中尝试了SQL语法,它似乎工作得很好。我对C和Access比较陌生 到目前为止,我所拥有的: OleDbCommand command = new OleDbCommand("Select * from Lid Where Naam Like @naam order by RangID desc, Creatiedatum, Naam", connection); command.Param
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 + "*"));
我尝试了一些变体,使用%而不是*,将其放在第一行而不是参数处,等等,但到目前为止似乎没有任何效果。我没有找到谷歌搜索的解决方案,也许我只是不知道该用谷歌搜索什么,就像我之前说的那样,我对C和Access非常陌生。有了OleDb,你肯定需要%而不是*作为通配符 我不知道.Net,但我猜这会有用
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));
使用OleDb,您肯定需要%而不是*作为通配符 我不知道.Net,但我猜这会有用
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));