ado求助,用它读写过大的字段值程序就死,请各位帮帮忙。
sql数据库,vc6,nt4.
tbl1表结构:name char(8),content text.
_ConnectionPtr m_pAdoConnection;
CString szSQL;
szSQL.Format("Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db1;Data Source=test");
m_pAdoConnection.CreateInstance(__uuidof(Connection));
m_pAdoConnection->Open(_bstr_t(szSQL),"","",-1);
//从tbl1中取出name='1'的记录,确定是唯一的
CString Holder="select content from tbl1 where name='1'";
int fieldcnt=0;
_RecordsetPtr prec;
_variant_t TheValue;
prec.CreateInstance(__uuidof(Recordset));
if(prec==NULL)
{
return ;
}
prec->Open(_variant_t(Holder),
m_pAdoConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
Holder.Empty();
fieldcnt=prec->Fields->Count;
while(!prec->adoEOF)
{
TheValue = prec->GetCollect("content");//这里程序死住。
if(TheValue.vt!=VT_NULL)
{
Holder=LPCSTR(_bstr_t(TheValue));
Holder.TrimLeft();Holder.TrimRight();
}
else
Holder="";
prec->MoveNext();
}
prec->Close();
}
以上就是主要代码。烦劳高手指点迷津。