高分求解:在sqlsever中能执行的长sql语句在程序中执行错误
select count(*) as jiegou from qibiji where (lic_num=1)and (((gujuan='超大型')or(yidong='超大型')or(yeya='超大型')or(luogan='超大型'))and((gujuan='中型')or(gujuan='小型')or(gujuan='无')or(yidong='中型')or(yidong='小型')or(yidong='无')or(yeya='中型')or(yeya='小型')or(yeya='无')or(luogan='中型')or(luogan='小型')or(luogan='无'))and(yidong!='大型')and(gujuan!='大型')and(yeya!='大型')and(luogan!='大型'))
用ado中的command对象执行,代码如下:
cmd.CreateInstance("ADODB.Command");
cmd->ActiveConnection=m_pConnection1;
cmd->CommandText=(_bstr_t)sql;
try
{
m_pRecordset1=cmd->Execute(NULL,NULL,adCmdText);
}
catch(_com_error em)
{
AfxMessageBox(em.ErrorMessage());
}
sql 为最上面的那个语句
在sqlsever中一切正常,但是在程序中提示:
IDispatch error #3092
然后继续提示:
runtime error!