方法如下  参数是(1) select * from anlv_pro where pro_type='卧式机' and pro_name like '*11*'
                 (2)table1
      public static DataSet ExecuteTextRet(string cmdText, string TableName)
        {
            DataSet ds = new DataSet();
            OleDbDataAdapter adp = new OleDbDataAdapter();
            OleDbCommand cmd = new OleDbCommand();
            try
            {
                PrepareCommand(cmd, CommandType.Text, cmdText);
                try
                {
                    adp.SelectCommand = cmd;
                    adp.Fill(ds, TableName);
                    return ds;
                }
                catch (OleDbException e)
                {
                    throw (new Exception(e.Message));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                DisposeCmd(cmd);
            }        }
用的access 数据库中有数据~~~~
为什么我读不到??????

解决方案 »

  1.   

    是不是条件这里空格问题啊。
    pro_type= '卧式机 '
      

  2.   

    报错误吗?
    看看你Catch到什么错误没有
      

  3.   

    没有报错   这段 select * from anlv_pro where pro_type= '卧式机 ' and pro_name like  '*11* ' 
    在access中也有数据~~~~
      

  4.   

    直接放到access查询器中有数据啊
      

  5.   

    还是在纳闷 查询语句如下:
    SELECT * from anlv_pro where pro_type='加工中心' and pro_name like '**' 
    在access中查询有数据~~~~
    但是用这个方法却没有数据   ~~~~~~超郁闷
    public static DataSet ExecuteTextRet(string cmdText, string TableName)
            {
                DataSet ds = new DataSet();
                OleDbDataAdapter adp = new OleDbDataAdapter();
                OleDbCommand cmd = new OleDbCommand();
                try
                {
                    PrepareCommand(cmd, CommandType.Text, cmdText);
                    try
                    {
                        adp.SelectCommand = cmd;
                        adp.Fill(ds, TableName);
                        return ds;
                    }
                    catch (OleDbException e)
                    {
                        throw (new Exception(e.Message));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    DisposeCmd(cmd);
                }        }
      

  6.   

    你用的ORACAL吧? 空格问题啊。。
      

  7.   

    汗   传说中的BT    ~~~~~
    在access 中查询要用SELECT * from anlv_pro where pro_type= '加工中心 ' and pro_name like  '*工地*'  
    但是在.net中还要用SELECT * from anlv_pro where pro_type= '加工中心 ' and pro_name like  '%工地% '  
      

  8.   

    select * from anlv_pro where pro_type= '卧式机 ' and pro_name like  "*"+你的变量+"*";通配符不能和变量写一起
      

  9.   

     select * from anlv_pro where pro_type= '卧式机 ' and pro_name like  '%11%'