zoukankan      html  css  js  c++  java
  • 关于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();
        }
       }

  • 相关阅读:
    洛谷 P1089.津津的储蓄计划
    AcWing 786.第k个数
    差分
    AcWing 798.差分矩阵
    AcWing 797.差分
    AcWing 796.子矩阵的和
    Python 初始—(项目 目录结构)
    Python 初始—(迭代器和生成器)
    Python 初始—(装饰器)
    Python 初始—(高阶函数)
  • 原文地址:https://www.cnblogs.com/flashicp/p/679991.html
Copyright © 2011-2022 走看看