点击添加按钮后出现错误提示:unknown error 0x800A0E7A
哪里错了呢,大家帮忙看看,谢谢
void CStudentDlg::OnButtonAdd()
{
// TODO: Add your control notification handler code here
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
try
{
HRESULT hr = m_pConnection.CreateInstance("ADODB.Connection");
if (SUCCEEDED(hr))
{
// 连接数据库---------------------------------- if (SUCCEEDED(m_pConnection->Open("driver={sql server};server=wmc0;DATABASE=fengchao;uid=fengchao;pwd=fengchao111","","",0))) {
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open("SELECT * FROM zhuce",_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); UpdateData(true);
m_pRecordset->AddNew();
m_pRecordset->PutCollect("name",_variant_t(m_name));
m_pRecordset->PutCollect("num",_variant_t(m_num));
m_pRecordset->Update(); m_pRecordset->Close();///关闭记录集
m_pConnection->Close();///关闭连接 AfxMessageBox("success!");
m_pRecordset->Close();
m_pConnection->Close(); return;
}
} }
catch (_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
}
哪里错了呢,大家帮忙看看,谢谢
void CStudentDlg::OnButtonAdd()
{
// TODO: Add your control notification handler code here
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
try
{
HRESULT hr = m_pConnection.CreateInstance("ADODB.Connection");
if (SUCCEEDED(hr))
{
// 连接数据库---------------------------------- if (SUCCEEDED(m_pConnection->Open("driver={sql server};server=wmc0;DATABASE=fengchao;uid=fengchao;pwd=fengchao111","","",0))) {
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open("SELECT * FROM zhuce",_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText); UpdateData(true);
m_pRecordset->AddNew();
m_pRecordset->PutCollect("name",_variant_t(m_name));
m_pRecordset->PutCollect("num",_variant_t(m_num));
m_pRecordset->Update(); m_pRecordset->Close();///关闭记录集
m_pConnection->Close();///关闭连接 AfxMessageBox("success!");
m_pRecordset->Close();
m_pConnection->Close(); return;
}
} }
catch (_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
}
提问题时标题要简明扼要地说明问题内容,切忌使用"急","求救"之类不能说明问题的标题
http://alphasun.betajin.com/ 遇到问题可以给我发消息,给我发信息时请附带原帖地址
DocWizard C++程序文档自动生成工具 | Wave OpenGL | HttpProxy | AjaxParser词法分析
其中第一个函数放在最前,第二个函数放在最后面!
Provider cannot be found. It may not be properly installed.
根据这个提示来找原因http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdaenumdm_2.asp