首页上一页 1 下一页尾页 1 条记录 1/1页
访问ACCESS数据库出错
发表在C语言图书答疑
2007-01-29
是否精华
是
否
版块置顶:
是
否
请老师指点,我将21章ODBC改写为ADO时已经做了如下定义:
_ConnectionPtr m_Connection;
_RecordsetPtr m_Rsp;
而且打开数据库成功,步骤如下:
HRESULT hr = m_Connection.CreateInstance(__uuidof(Connection));
m_Connection->ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.mystudentsys.mdb;Persist Security Info=False;";
hr=m_Connection->Open("","","",-1);
sprintf(m_szTmp, "数据库连接成功!");
HRESULT hr1 = m_Connection.CreateInstance(__uuidof(Recordset));
但在执行下面第2条语句时出错,不知为什么。
sql.Format("select * from tb_examinfo_sub");
m_Rsp = m_Connection->Execute(_bstr_t(sql), NULL, adCmdText) ;
_ConnectionPtr m_Connection;
_RecordsetPtr m_Rsp;
而且打开数据库成功,步骤如下:
HRESULT hr = m_Connection.CreateInstance(__uuidof(Connection));
m_Connection->ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.mystudentsys.mdb;Persist Security Info=False;";
hr=m_Connection->Open("","","",-1);
sprintf(m_szTmp, "数据库连接成功!");
HRESULT hr1 = m_Connection.CreateInstance(__uuidof(Recordset));
但在执行下面第2条语句时出错,不知为什么。
sql.Format("select * from tb_examinfo_sub");
m_Rsp = m_Connection->Execute(_bstr_t(sql), NULL, adCmdText) ;