求助ODBC:vc连接access的问题?

xklapple 2007-12-17 09:46:58
报错:在调用SQLFetchScroll/SQLExtendeFetch之前,没有列被绑定


1. CString strConnect;
2. CString strDBFile = "D:\\database1.mdb";
3. strConnect.Format(_T("ODBC;DRIVER={MICROSOFT ACCESS DRIVER (*.mdb)};DSN=abc1;UID=sa;PWD=;DBQ=%s"), strDBFile);

是第三句代码报错误.
求助.


...全文
100 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
raul_qu 2007-12-19
  • 打赏
  • 举报
回复
CRecordset::snapshot是快照静态记录集方式,
CRecordset::dynaset是动态记录集
raul_qu 2007-12-19
  • 打赏
  • 举报
回复
晕啊,几年不用都忘记咧,呵呵.

一般情况下,如果你只是用于查询的话,
CRecordset::snapshot
如果要对查询出来的记录集进行Edit(),AddNew(),Update()...
那么使用CRecordset::dynaset
shakaqrj 2007-12-18
  • 打赏
  • 举报
回复
CRecordset::dynaset A recordset with bi-directional scrolling. The membership and ordering of the records are determined when the recordset is opened, but changes made by other users to the data values are visible following a fetch operation. Dynasets are also known as keyset-driven recordsets.


CRecordset::snapshot A static recordset with bi-directional scrolling. The membership and ordering of the records are determined when the recordset is opened; the data values are determined when the records are fetched. Changes made by other users are not visible until the recordset is closed and then reopened.


CRecordset::dynamic A recordset with bi-directional scrolling. Changes made by other users to the membership, ordering, and data values are visible following a fetch operation. Note that many ODBC drivers do not support this type of recordset.


CRecordset::forwardOnly A read-only recordset with only forward scrolling.
For CRecordset, the default value is CRecordset::snapshot. The default-value mechanism allows the Visual C++ wizards to interact with both ODBC CRecordset and DAO CDaoRecordset, which have different defaults.

xklapple 2007-12-18
  • 打赏
  • 举报
回复
re:raul_qu .

按照你说得改的话,程序报错: ODBC 驱动程序不支持动态记录集.

我如果使用:rs.Open(CRecordset::forwardOnly, _T("select ID from tb_student"));
则可以查询到记录,但是不能使用 rs.MoveFirst(); 语句.

raul_qu 2007-12-18
  • 打赏
  • 举报
回复
rs.Open(CRecordset::none, _T("select * from tb_student"));
xklapple 2007-12-17
  • 打赏
  • 举报
回复
//连接数据库成功
1CRecordset rs(&db);
2 CString strSql;
3 strSql = _T("select * from tb_student"); //SQL语句
4 rs.Open(AFX_DB_USE_DEFAULT_TYPE, _T("select * from tb_student"));

刚才说错了,是第四句出的问题.


4,011

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 数据库
社区管理员
  • 数据库
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧