BOOL CLfinDlg::IfNewtb(CString strTfbh,CString strTb)
{
CString strSQL;
strSQL.Format( "select * from lfkxyt_info where Tfbh = '%s' and Edithion_New > '%d'",strTfbh,strTb )
if(!m_lfkinfoSet1->Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{MessageBox("打开数据库失败!","数据库错误",MB_OK);
return;
}

在字段Tfbh,Edition_New 都是文本类型的,上面select 对吗?(我想肯定不对)怎么改?
注:字段Tfbh 为编号,Edition_New 为年代。

解决方案 »

  1.   

    strSQL.Format( "select * from lfkxyt_info where Tfbh =  '%s ' and Edithion_New  >  '%d '",
      strTfbh.GetBuffer(strTfbh.GetLength()), atoi(strTb.GetBuffer(strTb.GetLength())) );
    strTfbh.ReleaseBuffer();
    strTb.ReleaseBuffer();
      

  2.   

    给数据库的就是一个字符串,sql语句是否正确要看你的转化好的字符窜是否合法。
    strSQL.Format( "select * from lfkxyt_info where Tfbh =  '%s ' and Edithion_New  >  '%d '",strTfbh,strTb ) 用的也不对吧,看看你的声明CString strTfbh,CString strTb
    应该是
    strSQL.Format( "select * from lfkxyt_info where Tfbh =  \'%s \' and Edithion_New  >  \'%s \'",strTfbh,strTb )
    要不你就改你的声明
      

  3.   

    我正在看,编译的错误提示是:
    F:\信息系统开发case\Mapman1.4\LfinDlg.cpp(179) : error C2511: 'IfNewtb' : overloaded member function 'int (class CString,class CString)' not found in 'CLfinDlg'
            f:\信息系统开发case\mapman1.4\lfindlg.h(16) : see declaration of 'CLfinDlg'。
    我认为是这句的问题。
    谢谢,还请继续 关注,麻烦各位了!!
      

  4.   

    F:\信息系统开发case\Mapman1.4\LfinDlg.cpp(179) : error C2511:  'IfNewtb ' : overloaded member function  'int (class CString,class CString) ' not found in  'CLfinDlg '
            f:\信息系统开发case\mapman1.4\lfindlg.h(16) : see declaration of  'CLfinDlg '。 
    这个提示信息,需要看看BOOL CLfinDlg::IfNewtb(CString strTfbh,CString strTb)的定义,
    怀疑LZ的定义是:IfNewtb(CString strTfbh,CString strTb),而没有返回值
    另外:strTb 这个变量的类型是什么?Edithion_New字段的定义又是什么?