关于C#中用access做数据库,使用like语句的问题
做了WindowForm程過程中,用到access做數據庫。在其中用到一條SQL語句 "select * from table where A like 'b*'"。返回結果中沒有一條。但是在access中的查詢中,運行此語句卻能返回結果。
?最后在程序中需要把*換成%
??StringBuilder sqlStr=new StringBuilder();
????sqlStr.Append( "select? COUNT(*) ");
????sqlStr.Append(" from ").Append(tableName);
????sqlStr.Append(" where " ).Append(tableName);
????sqlStr.Append("_Name");
????sqlStr.Append("='");
????sqlStr.Append(namestr);
????sqlStr.Append(" ' and ");
????sqlStr.Append(tableName);
????sqlStr.Append("_SORT LIKE '%B'");
才能返回非零結果.
try
???{
????int count = -1;
????dbop=new DatabaseOp(tablePath);
????string strSql=StrCheckName(TitleTableName,namestr);
????object obj = dbop.GetFirstValue(strSql);
????if (obj!=null)
????{
?????count = System.Convert.ToInt32(obj);
????}
????return count;
???}
???catch(Exception ex)
???{
????throw ex;
???}
???finally
???{
????if (dbop!=null)
????{
?????dbop.Close();
????}
???}
轉載于:https://www.cnblogs.com/flashicp/archive/2007/03/19/679991.html
總結
以上是生活随笔為你收集整理的关于C#中用access做数据库,使用like语句的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 东莞阿尔法罗密欧Giulia能爆发出多少
- 下一篇: window mobile 5.0截获来