select top 25 * from Exat_0 where fd <= K ORDER BY fd DESC 不能通过(K为int类型变量)K必须转换为具体的数值cstring s1=_T("select top 25 * from Exat_0 where fd <= K ORDER BY fd DESC ")s1调用Replace方法,将K转换为具体值,当然,K必须先转换为字符串
调试欢乐多
如下:
int K=151;
CString str;
str.Format("%d",K);// CString strSql = "select top 25 * from Exat_0 where fd <="+str+" ORDER BY fd DESC";
// m_adodc.SetRecordSource(strSql); m_adodc.SetRecordSource("select top 25 * from Exat_0 where fd <="+str+" ORDER BY fd DESC");
m_adodc.Refresh();
str.Format("%d",K);// CString strSql = "select top 25 * from Exat_0 where fd <="+str+" ORDER BY fd DESC";
// m_adodc.SetRecordSource(strSql); m_adodc.SetRecordSource("select top 25 * from Exat_0 where fd <="+str+" ORDER BY fd DESC");更简单点可以:
CString strSql;strSql.Format(_T("select top 25 * from Exat_0 where fd <=%d ORDER BY fd DESC"),K);
// m_adodc.SetRecordSource(strSql); m_adodc.SetRecordSource("select top 25 * from Exat_0 where fd <="+str+" ORDER BY fd DESC");
m_adodc.SetRecordSource(strSql);