无效指针
BOOL CFenKuangDlg::OnInitDialog()
{
CDialog::OnInitDialog();
int i;
CString m_kming;
try
{
m_pRecordset.CreateInstance("ADODB.Recordset");
CXGSApp *pApp=(CXGSApp *)AfxGetApp();
ASSERT_VALID(pApp);
m_pRecordset->Open("SELECT * FROM 粉矿综合性能",_variant_t((IDispatch*)theApp.m_pConnectSQL,true),adOpenStatic,adLockOptimistic,adCmdText); //AfxMessageBox("1");
m_pRecordset->MoveFirst();
for(i=1;i<=m_pRecordset->GetRecordCount();i++)
{
m_kming=(char *)(_bstr_t)m_pRecordset->GetCollect("矿物名称");
m_kuangming.AddString((LPCTSTR)m_kming);
m_pRecordset->Update();
m_pRecordset->MoveNext();
}
m_pRecordset->Close();
}
catch(_com_error e)///捕捉异常
{
CString str;
str.Format("读取粉矿综合性能表失败!\r\n错误信息:%s!",e.ErrorMessage());///显示错误信息
AfxMessageBox(str);
return false;
}
m_bNewUser = FALSE;
//初始化记录集对象
m_pRecordset1.CreateInstance("ADODB.Recordset");
//打开记录集
HRESULT hr = m_pRecordset1->Open("SELECT * FROM 粉矿综合性能",_variant_t((IDispatch*)theApp.m_pConnectSQL,true), adOpenDynamic, adLockPessimistic, adCmdText);
//如果打开记录集成功,则读取当前记录
if(SUCCEEDED(hr))
{
//读取当前记录
ReadData();
}
//根据当前记录的位置,重置各个控件的有效性
ResetControls();
//UpdateData(false);
return true;
}
这样读数据,弹出读取表失败,错误信息是:无效指针。
逐步运行后,几个局部变量的值是这样的,我看不懂
hInstance 0x00400000 {unused=9460301 } HINSTANCE__ *
unused 9460301 int
hPrevInstance 0x00000000 {unused=??? } HINSTANCE__ *
unused CXX0030: 错误: 无法计算表达式的值 int
lpCmdLine 0x00141f0c "" char *
0 char
nCmdShow 1 int
哪位能帮我解释一下,拜求了!