主题:get_Value(&var_Value) 怎么就错了啊
Fields * fields=NULL;
Field * field=NULL;
int MaxId;
if(!m_fConnected)
return FALSE;
if(strTableName.IsEmpty())
return FALSE;
HRESULT hr;
VARIANT varCount;
VARIANT var_Value;
CString strQuery;
strQuery.Format("select max(ID) from %s",strTableName);
_bstr_t query=strQuery;
_bstr_t source=m_strSource;
try
{
if(m_recordset->State==adStateOpen)
m_recordset->Close();
hr=m_recordset->Open(query,source,adOpenDynamic,adLockOptimistic,adCmdText);
hr=m_recordset->get_Fields(&fields);
varCount.lVal=0;
hr=fields->get_Item(varCount,&field);//获取第0列
field->get_Value(&var_Value);////为什么会出错?????????
MaxId=var_Value.lVal;
}
catch(_com_error &e)
{
MessageBox(e.ErrorMessage());
return FALSE;
}
帮帮忙了 晕了一个下午
帮帮忙 分析一下为什么?
错误:
First-chance exception in ADOTest.exe: 0xC0000005: Access Violation.