CString strSql="select * from table1 where='111'";
这样是能执行成功,并返回记录集
CSring a="111";
CString strSql="select * from table1 where=\'%a\'";
这样编译是没出错,但是 好象返回记录集为空的.
这是为什么呢?
求 [where]的具体写法~
这样是能执行成功,并返回记录集
CSring a="111";
CString strSql="select * from table1 where=\'%a\'";
这样编译是没出错,但是 好象返回记录集为空的.
这是为什么呢?
求 [where]的具体写法~
CString strSql="select * from table1 where='%"+a+"'";
CString strSql.Format("select * from table1 where='%s'",a);
1、CString strSql="select * from table1 where 字段名 like '%"+a+"'";
2、strSql.Format("select * from table1 where 字段名 like '%%s'",(LPCTSTR)a);
a.Replace("'","''");
CString strSql="";
strSql.Format("select * from table1 where='%s'",a);
CString strSql.Format("select * from table1 where='%s'",a);
copy zfive5(醉马不肖)
Sql.Format("SELECT * FROM account where account like '%s'",m_sShow1);
try{
m_pRecordset.CreateInstance("ADODB.Recordset");
==> m_pRecordset->Open(Sql, _variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
return 1;
}
--------------------Configuration: ATMSERVER - Win32 Debug--------------------
Compiling...
ATMSERVERDlg.cpp
G:\SOCK\ATMSERVER\ATMSERVERDlg.cpp(339) : error C2664: 'Open' : cannot convert parameter 1 from 'class CString' to 'const class _variant_t &'
Reason: cannot convert from 'class CString' to 'const class _variant_t'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.ATMSERVER.exe - 1 error(s), 0 warning(s)
Sql.Format("SELECT * FROM account where account like '%s'",m_sShow1);
BSTR bstrSQL = Sql.AllocSysString();/////////////////添加后试试
try{
m_pRecordset.CreateInstance("ADODB.Recordset");
==> m_pRecordset->Open(bstrSQL, _variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
return 1;
}
调试成功了,
能告诉我这是为什么呢 ??
下次可能还会在犯错的(寒~~~~~)