zoukankan      html  css  js  c++  java
  • 关于C#中用access做数据库,使用like语句的问题(转)

    关于C#中用access做数据库,使用like语句的问题

    作者:flashicp  来源:博客园  发布时间:2007-03-19 16:24   原文链接 [收藏]

    做了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();
        }
       }
  • 相关阅读:
    重要的环境变量
    常用的转义字符
    常用系统工作命令
    栈 队列 和 双向队列
    时间
    默认值字典
    Counter
    random
    22 内置常用模块01
    super
  • 原文地址:https://www.cnblogs.com/dabaopku/p/1670055.html
Copyright © 2011-2022 走看看