是在一个按纽事件
void CAMFCDlg::OnClickedSta()
{
。
}
中查询ACCESS:
m_pRecordset->Open("select * from hiyt",
_variant_t((IDispatch *)m_pConnection,true),
adOpenDynamic,
adLockOptimistic,
adCmdText);
编译无错,但运行出现Debug Error! 调试信息为:
AfxGetThread 返回 0x00430388 class CAMFCApp theApp {CAMFCApp <错误的指针>} CWinThread *//********************************************************************************************但是改为_variant_t((IDispatch *)theApp.m_pConnection,true),肯定是不行的,请问在局部怎么用theApp?
void CAMFCDlg::OnClickedSta()
{
。
}
中查询ACCESS:
m_pRecordset->Open("select * from hiyt",
_variant_t((IDispatch *)m_pConnection,true),
adOpenDynamic,
adLockOptimistic,
adCmdText);
编译无错,但运行出现Debug Error! 调试信息为:
AfxGetThread 返回 0x00430388 class CAMFCApp theApp {CAMFCApp <错误的指针>} CWinThread *//********************************************************************************************但是改为_variant_t((IDispatch *)theApp.m_pConnection,true),肯定是不行的,请问在局部怎么用theApp?
解决方案 »
- 请各位大侠解决一下,vc6.0和msdn 2008怎么关联起来?
- 图像显示问题
- 关于内存共享节的问题。。。比较诡异呀。。。
- 关于tdxbarcontrol窗口类
- 在线等!!请问一下怎样测试算法的速度??
- 新人没分,请教个问题,有关windows api参数传递指针和地址的问题,谢谢
- 为什么我自己不能删除自己发过的帖子?
- 如何制作背景透明的控件
- 怎么实现打印报表功能?
- 以前好的.莫名奇妙出现Error spawning 'vcspawn.exe'. The build could not be performed.
- InstallShield12生成安装程序,500K的文件打包后成了6M,
- 这个怎么解决...急...
为什么说_variant_t((IDispatch *)theApp.m_pConnection,true)不行?
_ConnectionPtr m_pConnection;和AfxOleInit();都要在void CAMFCDlg::OnClickedSta()之外而不能在局部定义和初始化?
m_pConnection初始化在哪?
_ConnectionPtr m_pConnection;)都一样在编译时出现:error C2039: 'm_pConnection' : is not a member of 'CAMFCApp'
自然编译出错,
AfxOleInit();
m_pConn.CreateInstance("ADODB.Connection");
try{
m_pConn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb","","",adConnectUnspecified);
}catch(_com_error e){
AfxMessageBox("连接数据库失败!");
}
**************************************************************************
_ConnectionPtr m_pConnection;
// 初始化COM,创建ADO连接等操作
AfxOleInit();
m_pConnection.CreateInstance(__uuidof(Connection)); try
{
// 打开本地Access库
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=hmeghy.mdb","","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox(L"数据库连接失败,确认数据库hmeghy.mdb是否在当前路径下!");
return ;
} _RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset)); try
{
m_pRecordset->Open("select * from hiyt",
_variant_t((IDispatch *)theApp.m_pConnection,true),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}//**********************************************************************************
上面是写在按纽事件void CAMFCDlg::OnClickedSta(){。。}中的源码,当把_ConnectionPtr m_pConnection;取出在AMFCDlg.h中初始化时还是一样在编译时出现错误:error C2039: 'm_pConnection' : is not a member of 'CAMFCApp'
_RecordsetPtr
不要用局部变量
写成对话框类的成员
public:
_ConnectionPtr m_pConnection; 不行吗?
_variant_t((IDispatch *)m_pConnection,true),
c:\documents and settings\bl\桌面\a-mfc\a-mfc.h(17) : see declaration of 'CAMFCApp'
AfxGetThread 返回 0x00430388 class CAMFCApp theApp {CAMFCApp <错误的指针> } CWinThread *
_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
__in LPTSTR lpCmdLine, int nCmdShow)
{
// call shared/exported WinMain
return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}hPrevInstance 0x00000000 {unused=??? } HINSTANCE__ *
unused CXX0030: 错误: 无法计算表达式的值
[email protected]