vc sql2000 连接数据库失败! Unknown error 0x800A0CC1

wyx100 2012-11-20 03:15:32
连接数据库失败!
错误信息:Unknown error 0x800A0CC1


http://bbs.csdn.net/topics/30156411
这显然是一个错误号而不是错误的地址。

msdn的解释如下:Item cannot be found in the collection corresponding to the requested name or ordinal.

见http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdaenumdm_2.asp

对于ado不是很熟,在往下就不知道了。

代码

sql="select * from test";
m_pRecordset = m_AdoConn.GetRecordSet((_bstr_t)sql);

try
{
m_pRecordset-> AddNew();
m_pRecordset-> PutCollect( "ID ", _variant_t("1"));
m_pRecordset-> Update();
} catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
} catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
}


执行到 m_pRecordset-> PutCollect( "ID ", _variant_t("1"));
报错

什么原因啊?
...全文
338 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
wyx100 2012-11-23
  • 打赏
  • 举报
回复
谢谢hfz8867879、 oyljerry、大家,结贴给分
wyx100 2012-11-23
  • 打赏
  • 举报
回复
try { m_pRecordset-> AddNew(); m_pRecordset-> PutCollect( "ID ", _variant_t("1")); m_pRecordset-> Update(); } catch(_com_error *e) m_pRecordset-> PutCollect( "ID ", _variant_t("1")); 改为 m_pRecordset-> PutCollect( "ID", _variant_t("1")); ID里面不能有空格
wyx100 2012-11-21
  • 打赏
  • 举报
回复
error C2039: 'GetInterfacePtr' : is not a member of 'ADOConn'
九州剑王 2012-11-20
  • 打赏
  • 举报
回复
m_pRecordset->CursorLocation = adUseClient; m_pRecordset->Open("select * from test", // 查询表中所有字段 m_AdoConn.GetInterfacePtr(), // 获取库接库的IDispatch指针 adOpenDynamic, adLockOptimistic, adCmdText); m_pRecordset-> MoveFirst(); m_pRecordset->Requery(adOptionUnspecified); m_pRecordset-> AddNew(); m_pRecordset-> PutCollect( "ID ", _variant_t("1")); m_pRecordset-> Update();
wyx100 2012-11-20
  • 打赏
  • 举报
回复
m_pRecordset-> PutCollect( "ID ", _variant_t("1"));插到test表
九州剑王 2012-11-20
  • 打赏
  • 举报
回复
引用 7 楼 wyx100 的回复:
用m_pRecordset-> PutCollect( "ID ", _variant_t("1"));为什么实现不了
这又不是往你的表里面插的吧?
wyx100 2012-11-20
  • 打赏
  • 举报
回复
用m_pRecordset-> PutCollect( "ID ", _variant_t("1"));为什么实现不了
九州剑王 2012-11-20
  • 打赏
  • 举报
回复
"select * from test",sqlserver是这么选择表的?我怎么觉得是select 、use
九州剑王 2012-11-20
  • 打赏
  • 举报
回复
直接用_CommandPtr去执行条插入语句不就行了?你这么弄我觉得明显是给得到的数据集里面添加,和给数据表添加完全两码事吧?
wyx100 2012-11-20
  • 打赏
  • 举报
回复
sql="select * from test"; m_pRecordset = m_AdoConn.GetRecordSet((_bstr_t)sql); 取没取出来东东很值得怀疑啊 作用是 选择到test表,要给该表添加新记录
wyx100 2012-11-20
  • 打赏
  • 举报
回复
ID列名是正确。。。。
九州剑王 2012-11-20
  • 打赏
  • 举报
回复
sql="select * from test"; m_pRecordset = m_AdoConn.GetRecordSet((_bstr_t)sql); 取没取出来东东很值得怀疑啊
oyljerry 2012-11-20
  • 打赏
  • 举报
回复
ID列名是否正确。

4,011

社区成员

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

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