做了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();
    }
   }

相关文章:

  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2022-01-03
  • 2022-01-07
  • 2021-05-19
  • 2022-01-06
猜你喜欢
  • 2021-10-11
  • 2021-11-15
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
相关资源
相似解决方案