错误描述,在按下添加按钮时,报错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());
}
}
解决方案 »
- Active控件的刷新问题
- VC中关于如果改变鼠标形状的问题?
- CBitmapButton用法?????
- 怎样才能得到YYYYMMDD格式的日期?
- 我做了一个Dialog,我把 Dialog嵌入到别的窗口中,但是Dialog有边缘,我想把边缘给去掉,好让Dialog和别的窗口相融合,怎么做呢?
- Help。WaitForSingleObject()的用法。
- 请问VC中有什么方法可以代替全局变量》??急
- WSAStartup + gethostbyname
- mfc VS asm,图像处理的苦恼?
- 关于CSocket的问题!
- 编译hellowin.c 出现这两个错误,error LNK2001: fatal error LNK1120: 谢谢大家了。
- 如何打印一个对话框?
m_pRecordset->Open("select * from 套管数据 ",_variant_t((IDispatch*)m_pConnection,true),adOpenDynamic,adLockOptimistic,adCmdText);
颠倒一下看看
2。是不是目前的表中为空呀!