错误描述,在按下添加按钮时,报错unknown error 0x800A0C93,通过调试,我初步确定错误出现在
语句:TESTHR(picRs->AddNew(&rs));
但往后就不知道了,还请高手指教源程序如下:
void CTaoGuanDlg::OnButtonadd()
{
// TODO: Add your control notification handler code here if(!UpdateData())
return;
if(m_id==0)
{
AfxMessageBox("套管序号不能为空");
}
try
{
m_pRecordset->Open("select 序号 from 套管数据",(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText);
int id=1;
if(!m_pRecordset->adoEOF)
{
_variant_t TheValue;
//从系列中获取新的序号
TheValue=m_pRecordset->Fields->GetItem((short)0)->Value;
id=TheValue.iVal;
}
m_pRecordset->Close(); CTaoGuanDataRs rs;
IADORecordBindingPtr picRs(m_pRecordset);
m_pRecordset->Open("select * from 套管数据 ",_variant_t((IDispatch*)m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText);
//绑定记录集
TESTHR(picRs->BindToRecordset(&rs)); //给新添加的记录赋值
rs.m_l_id=m_id;
rs.m_d_tgwj=m_tgwj;
strcpy(rs.m_sz_tggcwj,m_tggcwj);
rs.m_d_tgbh=m_tgbh;
strcpy(rs.m_sz_jlw,m_jlw);
strcpy(rs.m_sz_nlw,m_nlw);
//调用IADORecordBing接口的AddNew方法添加新的数据,并显示到界面上
TESTHR(picRs->AddNew(&rs));
CString str;
str.Format("%d",id);
m_listTGData.InsertItem(id,str);
str.Format("%f",m_tgwj);
m_listTGData.SetItemText(id,1,str);
m_listTGData.SetItemText(id,2,m_tggcwj); str.Format("%f",m_tgbh);
m_listTGData.SetItemText(id,3,str);
m_listTGData.SetItemText(id,4,m_jlw);
m_listTGData.SetItemText(id,5,m_nlw);
m_pRecordset->Close();
}
catch (_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
}
语句:TESTHR(picRs->AddNew(&rs));
但往后就不知道了,还请高手指教源程序如下:
void CTaoGuanDlg::OnButtonadd()
{
// TODO: Add your control notification handler code here if(!UpdateData())
return;
if(m_id==0)
{
AfxMessageBox("套管序号不能为空");
}
try
{
m_pRecordset->Open("select 序号 from 套管数据",(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText);
int id=1;
if(!m_pRecordset->adoEOF)
{
_variant_t TheValue;
//从系列中获取新的序号
TheValue=m_pRecordset->Fields->GetItem((short)0)->Value;
id=TheValue.iVal;
}
m_pRecordset->Close(); CTaoGuanDataRs rs;
IADORecordBindingPtr picRs(m_pRecordset);
m_pRecordset->Open("select * from 套管数据 ",_variant_t((IDispatch*)m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText);
//绑定记录集
TESTHR(picRs->BindToRecordset(&rs)); //给新添加的记录赋值
rs.m_l_id=m_id;
rs.m_d_tgwj=m_tgwj;
strcpy(rs.m_sz_tggcwj,m_tggcwj);
rs.m_d_tgbh=m_tgbh;
strcpy(rs.m_sz_jlw,m_jlw);
strcpy(rs.m_sz_nlw,m_nlw);
//调用IADORecordBing接口的AddNew方法添加新的数据,并显示到界面上
TESTHR(picRs->AddNew(&rs));
CString str;
str.Format("%d",id);
m_listTGData.InsertItem(id,str);
str.Format("%f",m_tgwj);
m_listTGData.SetItemText(id,1,str);
m_listTGData.SetItemText(id,2,m_tggcwj); str.Format("%f",m_tgbh);
m_listTGData.SetItemText(id,3,str);
m_listTGData.SetItemText(id,4,m_jlw);
m_listTGData.SetItemText(id,5,m_nlw);
m_pRecordset->Close();
}
catch (_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
}
解决方案 »
- 在一个窗口类中调用另一个窗口类函数出错
- 如何把小程序(如:计算器)做成可以给别人调用
- 在对话框上CMSChart控件怎么添加?谢谢
- ####有[问题]请教各位前辈!请指点一下
- VC6中,如何编程读写U盘(外置USB接口的移动存储器)?
- 给个键盘钩子例
- 十万火急!!!如何把CRICHEDIT 中的内容输出显示到多文档视图的其中一个文档中?<在线给分>
- Programming windows中关于绘图的一个疑问!
- 关于短消息的内容监控
- to ELine 和所编过五指棋的人。
- 编译hellowin.c 出现这两个错误,error LNK2001: fatal error LNK1120: 谢谢大家了。
- 如何打印一个对话框?
m_pRecordset->Open("select * from 套管数据 ",_variant_t((IDispatch*)m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText);
颠倒一下看看
2。是不是目前的表中为空呀!