我用ADO的方式从数据中读数据,但是每次总是读出那张表的一部分记录,同样的SQL语句在Sql plus中可以读出所有的记录,不明白是怎么一回事情?下面是我写的代码,请高手帮忙。在数据中是有Tserver1这条记录的,用SQL plus也能查的到,但是用程序不能读出来。
BOOL CCTIAppView::ReadDataBase(void)
{
//COM组件初始化
::CoInitialize(NULL); _ConnectionPtr pConnection;
_RecordsetPtr  pRecordset; try
{
pConnection.CreateInstance(__uuidof(Connection));

CString strSql;
strSql.Format("select * from initparameter");

m_strConn.TrimRight(' ');
pConnection->Open(m_strConn.AllocSysString(),"","",-1); pRecordset.CreateInstance(__uuidof(Recordset));
BSTR bstrSQL = strSql.AllocSysString();

pRecordset->CursorLocation = adUseClient;
pRecordset->Open(bstrSQL,_variant_t((IDispatch*)pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText); if(!(pRecordset->BOF && pRecordset->adoEOF))
{
while(!pRecordset->adoEOF)
{
_variant_t vItem;
vItem = pRecordset->GetCollect("PARAITEM"); _variant_t vValue;
vValue = pRecordset->GetCollect("PARAVALUE"); if(vItem.vt != VT_NULL)
{
CString Item;
Item = (char*)_bstr_t(vItem);
Item.TrimRight(' '); CString Value;
Value = (char*)_bstr_t(vValue);
Value.TrimRight(' '); CString sItem;
         sItem.Format("Tserver%d",  1);
sItem.TrimRight(' '); if(Item.CompareNoCase(sItem) == 0)
{
AfxMessageBox(Value);
}
} pRecordset->MoveNext();
}
}

pRecordset->Close();
pConnection->Close();          }
catch(_com_error e)
{
CString pStr;
try
{
if(pRecordset != NULL)
pRecordset->Close();
if(pConnection != NULL)
pConnection->Close();
}
catch(_com_error e)
{
pStr = "数据库操作异常,请检查计算机网络连接!";
pStr +=e.ErrorMessage(); ::MessageBox(NULL,pStr,"CTI告警!",MB_OK|MB_ICONSTOP);
} ::CoUninitialize(); return FALSE;
}
catch(...)
{
::MessageBox(NULL ,"请检查数据库连接!","告警",MB_OK|MB_ICONSTOP); ::CoUninitialize(); return FALSE;
} ::CoUninitialize(); return TRUE;
}