双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

无效指针

liying828772 liying828772 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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

哪位能帮我解释一下,拜求了!




...全文
评论 12
收藏 已收藏
分享
返回顶部
liying828772
数据库 4,017 成员 39,805 内容