要查询记录中所有车牌号(cph)以aa(一个字符串对象)开头的记录?
我是这样写的:
    _bstr_t sql="SELECT * FROM table WHERE CPH LIKE'" + sCph_head + "%'";

    m_pRecordset=pConn->Execute(sql,NULL,adCmdText);
int count=m_pRecordset->RecordCount ;
    count等于-1,如何写这条语句。
   找不到到底是返回0还是-1??

解决方案 »

  1.   

    什么数据库啊?
    打开recordset不是m_pRecordset.Open****吗?
      

  2.   

    你那样返回的值不能用的
    用过虑好些
    m_pRecordset->Filter=过滤条件
      

  3.   

    你的表名字是table太奇怪了了吧,table是保留字
    _bstr_t sql="SELECT * FROM table WHERE CPH LIKE'" + sCph_head + "%'";
    其它的倒没问题
      

  4.   

    楼主呢?
    提醒你Access数据库的通配符是*号
      

  5.   

    _bstr_t sql="SELECT * FROM yourtable WHERE cph LIKE '" + sCph_head + "*'";

        m_pRecordset=pConn->Execute(sql,NULL,adCmdText);
    int count=m_pRecordset->RecordCount ;
      

  6.   

    _bstr_t sql="SELECT * FROM [table] WHERE CPH LIKE'" + sCph_head + "%'";
      

  7.   

    count=-1,标识sql语句出错或查询记录数目无法确定,使用getlasterror()得到出错码。
    sql返回无记录,则count=0;