数据库Ado记录绑定错误 [英] Database Ado Record Binding error

查看:55
本文介绍了数据库Ado记录绑定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读一本书中的示例"21天之内自学Visual C ++".
有关于ADO的章节.我所做的示例不起作用,据我所知,没有键入错误.
它可以编译,但是出现程序崩溃和错误(调试时):-
<未处理的异常...访问冲突>在release()所在的行-参见下面的代码
无效的CDbAdoDoc :: DeleteContents()
{
//TODO:在此处添加您的专用代码和/或调用基类
//关闭记录集
如果(m_pRs)
m_pRs-> Close();
//我们是否有指向记录绑定的有效指针?
如果(m_piAdoRecordBinding)
//发布
m_piAdoRecordBinding-> Release(); //在这里崩溃,如果我注释掉,它可以正常运行
//将记录指针设置为NULL
m_pRs = NULL;
//关闭COM环境
CoUninitialize();
CDocument :: DeleteContents();
}
正确声明了m_piAdoRecordBinding

I''m going through an example in a book ''Teach yourself Visual C++ in 21 days''.
There''s chapter about ADO. The example I have made does not work and as far as I can see there is no typing errors.
It compiles ok, but I get a program crash and the error (when debugging) :-
< Unhandled exception ... access violation > at the line where it release() - see the code below
void CDbAdoDoc::DeleteContents()
{
// TODO: Add your specialized code here and/or call the base class
//Close the recordset
if (m_pRs)
m_pRs->Close();
//Do we have a valid pointer to the record binding?
if (m_piAdoRecordBinding)
//Release it
m_piAdoRecordBinding->Release(); //crash here, if I comment it out it runs ok
//Set the record pointer to NULL
m_pRs = NULL;
//Shut down the COM environment
CoUninitialize();
CDocument::DeleteContents();
}
m_piAdoRecordBinding is correctly declared

推荐答案

首先要想到的是,您是否早先将类绑定到了记录集?像这样的东西:
First thing that comes in mind is that have you binded the class earlier to the recordset? Something like:
m_piAdoRecordBinding->BindToRecordset(...)


这篇关于数据库Ado记录绑定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆