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哪位能帮我解释一下,拜求了!
{
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哪位能帮我解释一下,拜求了!
解决方案 »
- vs 2010调试问题
- 线程
- 我怎么获取不到窗口句柄
- 学习Com Com+ 有用吗?
- makefile文件如何在VC6中使用?
- 怎么使用一个指向类中的数组的数组指针 ????急!!!!
- 高手请进,关于constructor的怪异表现
- 由于计算机所能表示和处理的数的有效数字位数有限,因此在进行大数运算时会产生溢出要求用C语言编写程序实现大整数的四则运算(加、减、乘、除)。
- 请问长沙哪里可以买到thinking in c++ e文的和设计模式这两本书卖?定王台有吗?
- 如何压缩二进制文件及反向解压的算法--源代码??
- vc做一个简单的窗口 使用自定义图标 不使用MFC
- 请帮忙看一下这个自定义消息无法执行
我的代码是没错的,是数据库里面出现问题了。列名跟代码不一致导致的
而你是直接属性名就不同 更厉害!!汗.........