m_pZoneSet.CreateInstance(__uuidof(Recordset));
try
{
m_pZoneSet->Open( "SELECT * FROM table_3" ,
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
try
{
while(!m_pZoneSet->adoEOF)
{
var=m_pZoneSet->GetCollect("zonenum");
if(var.vt!=VT_NULL)
strnum=(LPCSTR)_bstr_t(var); //strnum将是下一步的查询条件之一
var=m_pZoneSet->GetCollect("zonename");
if(var.vt!=VT_NULL)
strname=(LPCSTR)_bstr_t(var);
m_pSet.CreateInstance(__uuidof(Recordset));
strsql.Format("SELECT * FROM table_2 WHERE zone=%s AND day=%d AND month=%d AND year=%d",zonenum,day_day,day_month,day_year);//将上一步得到的strnum作为条件之一,执行出错,把这个条件去掉就没问题了,问题就出在这上面,可是我觉得没问题啊,那位帮忙看一下
_bstr_t sql=strsql;
try
{
m_pSet->Open( sql,
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
。。m_pZoneSet->MoveNext();//是第一个记录集
}//while
}//try
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
try
{
m_pZoneSet->Open( "SELECT * FROM table_3" ,
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
try
{
while(!m_pZoneSet->adoEOF)
{
var=m_pZoneSet->GetCollect("zonenum");
if(var.vt!=VT_NULL)
strnum=(LPCSTR)_bstr_t(var); //strnum将是下一步的查询条件之一
var=m_pZoneSet->GetCollect("zonename");
if(var.vt!=VT_NULL)
strname=(LPCSTR)_bstr_t(var);
m_pSet.CreateInstance(__uuidof(Recordset));
strsql.Format("SELECT * FROM table_2 WHERE zone=%s AND day=%d AND month=%d AND year=%d",zonenum,day_day,day_month,day_year);//将上一步得到的strnum作为条件之一,执行出错,把这个条件去掉就没问题了,问题就出在这上面,可是我觉得没问题啊,那位帮忙看一下
_bstr_t sql=strsql;
try
{
m_pSet->Open( sql,
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
。。m_pZoneSet->MoveNext();//是第一个记录集
}//while
}//try
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
解决方案 »
- 应用程序后台运行问题求解
- 我不在乎分,但我讨厌这种行为!
- 【快问快答快给分】DAO方式连接ACCESS数据库,如何设置数据库的全局变量
- 如何在CRichEditCtrl或CRichEditView里画一些线条作为背景(100分)
- http://vcworm.51.net/interface/fullscreen.htm中的全屏显示,我用mdi,为什么全屏后,下面会留下一个状态拦高的灰黑区域?如何解决(类
- 有一个按钮,点一下读文件,打开一个对话框,但这个对话框的标题必须是从文件中读出来的,哪样做最简单?我这样写出错了。
- directshow还有多久被淘汰,值不值得去学?
- 做一个vc dll,封装twain扫描功能,遇到一个handle问题???在线等!
- USB驱动安装后自动运行的问题
- 奇怪。为什么总是空记录?
- 为什么执行不到CFormView::OnClose?
- 怎么使cedit只能输入数字(包括小数)?
---------------有个地方打错了,zonenum应为上面的strnum,但程序中并没有打错。
//%s的两端应该加单引号。
实际上简单的方法是将SQL语句直接在数据库中执行,可以快速的找到错误。