我的程序如下: void CAccountDBSSDlg::OnBtnIncomeAdd() { // TOD Add your control notification handler code here
if(!UpdateData()) return; CString txtType = m_dcIncome.GetText(); if(txtType.IsEmpty()){ AfxMessageBox("类型不能为空"); return; } //获取收入时间; CString strDate = m_oleIncome.Format("%Y-%m-%d"); try { // _RecordsetPtr m_pRecordset; m_pConnection.CreateInstance(_uuidof(Connection)); //初始化Connection指针 m_pRecordset.CreateInstance("ADODB.Recordset");//初始化Recordset指针 m_pRecordset->Open("Select seq_income_id.NEXTVAL from dual",(IDispatch*)m_pConnection,adOpenDynamic,adLockOptimistic,adCmdText); int id = 1; if(!m_pRecordset->adoEOF) { _variant_t TheValue; //从系列中获取新的收入ID值; TheValue = m_pRecordset->Fields->GetItem((short)0)->Value; if(TheValue.vt != VT_NULL) id = TheValue.iVal; } m_pRecordset->Close();
_variant_t RecordsAffected; //插入新的收入信息记录; CString sql; sql.Format("insert into income_info_tab(income_id,""income_date,income_type,money,""description) values(""%d,""to_date('%s','yyyy-mm-dd'),""'%s',%.2f,'%s')",id,strDate,txtType,m_dbIncomeMoney,m_strIncome); TRACE(sql); m_pConnection->Execute(_bstr_t(sql),&RecordsAffected,adCmdText); //刷新ADO数据控件的数据,从而更新数据显示 m_adoIncomeDataCtrl.Refresh (); InitControl(); } catch(_com_error e)//异常处理; { AfxMessageBox(e.ErrorMessage()); AfxMessageBox("测试"); } 编译是能通过的,但是运行出来后操作就出现有“0x800A0E7D”这些字符的提示框,谢谢高手指教