CString strSQL;
strSQL.Format(L"select 通话时刻,主叫号码 from ak120.TAlarmCall;");//将CString对象设置为指定的字符串
int Ret;
Ret=m_dbi.DoOpen(strSQL.GetBuffer(0)) ; //GetBuffer就是返回当前这个CString类中的字符串头指针
printf("Ret=%d\n",Ret);
if(Ret!= 1)
{
printf("failed to select!\n");
} while (!m_dbi.Eof())
{
//
CString strBuf;
m_dbi.Field(L"主叫号码",strBuf);
printf("strBuf=%s\n",strBuf);
m_dbi.DoNext();
}INT CAdoDBI::DoOpen(CString strSQL)
{
try
{
if (ReConnect() != 0) //检查数据库连接是否断开,如果断开则重新连接
return -1;
//判断结果集指针是否还连接着别的结果集,连接着则断开
if (m_pRecordset->State != adStateClosed)
m_pRecordset->Close();
m_pCommand->ActiveConnection = m_pConnection; //设置连接指针
m_pCommand->CommandType = adCmdText; //设置串类型为SQL语句
//CString sSql=strSQL;
m_pCommand->CommandText = strSQL.GetBuffer();//.AllocSysString(); //设置SQL语句
m_pRecordset = m_pCommand->Execute(NULL,NULL,adCmdText);
// if(First()==0)
// return 0;
return m_pRecordset->RecordCount;
}
catch(_com_error &e) //COM异常
{
/* CString sError; //日志记录
sError.Format("执行返回结果集的数据库操作(%s)出错,",strSQL);
sError += "错误源:";
sError += e.Source();
sError += ",错误描述:";
sError += e.Description();
sError += "\n";
TRACE(sError);
*/
CString sError;
sError.Format(L"执行返回结果集的数据库操作(%s)出错,错误源:%s,错误描述:%s\n",strSQL,e.Source(),e.Description());
m_oLog.ErrorLog(sError,1);
return -1;
}
catch(...) //其他异常
{
CString sOther; //日志记录
sOther.Format(L"执行返回结果集的数据库操作(%s)异常。",strSQL);
TRACE(sOther);
m_oLog.ErrorLog(sOther,1);
return -1;
}
}
strSQL.Format(L"select 通话时刻,主叫号码 from ak120.TAlarmCall;");//将CString对象设置为指定的字符串
int Ret;
Ret=m_dbi.DoOpen(strSQL.GetBuffer(0)) ; //GetBuffer就是返回当前这个CString类中的字符串头指针
printf("Ret=%d\n",Ret);
if(Ret!= 1)
{
printf("failed to select!\n");
} while (!m_dbi.Eof())
{
//
CString strBuf;
m_dbi.Field(L"主叫号码",strBuf);
printf("strBuf=%s\n",strBuf);
m_dbi.DoNext();
}INT CAdoDBI::DoOpen(CString strSQL)
{
try
{
if (ReConnect() != 0) //检查数据库连接是否断开,如果断开则重新连接
return -1;
//判断结果集指针是否还连接着别的结果集,连接着则断开
if (m_pRecordset->State != adStateClosed)
m_pRecordset->Close();
m_pCommand->ActiveConnection = m_pConnection; //设置连接指针
m_pCommand->CommandType = adCmdText; //设置串类型为SQL语句
//CString sSql=strSQL;
m_pCommand->CommandText = strSQL.GetBuffer();//.AllocSysString(); //设置SQL语句
m_pRecordset = m_pCommand->Execute(NULL,NULL,adCmdText);
// if(First()==0)
// return 0;
return m_pRecordset->RecordCount;
}
catch(_com_error &e) //COM异常
{
/* CString sError; //日志记录
sError.Format("执行返回结果集的数据库操作(%s)出错,",strSQL);
sError += "错误源:";
sError += e.Source();
sError += ",错误描述:";
sError += e.Description();
sError += "\n";
TRACE(sError);
*/
CString sError;
sError.Format(L"执行返回结果集的数据库操作(%s)出错,错误源:%s,错误描述:%s\n",strSQL,e.Source(),e.Description());
m_oLog.ErrorLog(sError,1);
return -1;
}
catch(...) //其他异常
{
CString sOther; //日志记录
sOther.Format(L"执行返回结果集的数据库操作(%s)异常。",strSQL);
TRACE(sOther);
m_oLog.ErrorLog(sOther,1);
return -1;
}
}
解决方案 »
- 求个统计24小时内登陆过的语句
- 删除重复的记录,100跪求
- 在其它机器上恢复数据库出错
- 在原有SQL server2000的系统上装SQL2005后,附加2005数据库602错误
- 如何使報表調用數據速度快些,Tks
- 如何将单个SSIS包部署到服务器(高手请进)
- 建立索引和主键是不是一回事
- 我相把一个数据库中的一个表数据,复制到另一个数据库的另一个表怎么做,我只复制其中的几个字段的数据?
- link服务器和openrowset()函数的效率?
- 请教如何把ORACLE client打包?急!急!
- 各位大哥,请教关于游标的使用应用?
- 求一本《sql server 2005宝典》(刘志勇编)的 光盘内容
Ret=-1
failed to select!
strBuf=1
strBuf=1
strBuf=1
请按任意键继续. . .