马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
两段基本相同的代码,执行起来却一个没异常而另一个异常!真不知道为什么会如此!两段代码的SQL语句在SQL SERVER里面运行又是没有错误的!
运行正常的代码段:
if(Choose==2){
Connect(Server);
_bstr_t vSQL;
vSQL="SELECT * FROM BOOK WHERE FLAG_BORROW=\'Y\' OR FLAG_BORROW=\'y\'";
m_pRecordset->Open(vSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(!m_pRecordset->adoBOF||!m_pRecordset->adoEOF)
for(m_pRecordset->MoveFirst();!m_pRecordset->adoEOF;m_pRecordset->MoveNext()){
char FID[100];
strcpy(FID,(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("BOOK_ID"));
if(!strcmp(ID,FID)){
Disconnect();
return 1;
}//if(find)
}//for()
Disconnect();
return 0;
}//if(Choose==2),find if there is the book can be borrowed
运行错误的代码段:
if(Choose==3){
Connect(Server);
_bstr_t vSQL;
vSQL="SELECT * FROM BORROW_RETURN WHERE READER_ID=";
strcat(vSQL,"\'");
strcat(vSQL,NowReader->ID);
strcat(vSQL,"\'");
m_pRecordset->Open(vSQL,m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);//经测试,这是出现异常的语句
if(!m_pRecordset->adoBOF||!m_pRecordset->adoEOF)
for(m_pRecordset->MoveFirst();!m_pRecordset->adoEOF;m_pRecordset->MoveNext()){
char FID[100];
strcpy(FID,(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("BOOK_ID"));
if(!strcmp(ID,FID)){
Disconnect();
return 1;
}//if(find)
}//for()
Disconnect();
return 0;
}//if(Choose==3),find if the present reader has borrowed the book
究竟两段代码不同在哪里啊!?望各位高手指教!
[ 本帖最后由 拜仁拜仁 于 2008-6-26 16:58 编辑 ] |