"不能为新插入的行确定标识" 什么错误??? 急 在线等!

mikecat888 2003-05-30 10:30:12
AnnounceID为一自动编号字段,运行下述代码出现如下错误:
Provider 错误 '80040e1b'
不能为新插入的行确定标识。

/bbs/Savewrite.asp,行150

-------------------------------------------------------
代码如下:
-------------------------------------------------------
Set DataConn = Server.CreateObject("ADODB.Connection")
dataconn.open connstr
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set InsertCursor = Server.CreateObject("ADODB.Recordset")
cmdTemp.CommandText="SELECT *, UserName FROM bbs1 WHERE (UserName IS NULL)"
cmdTemp.CommandType = 1
Set cmdTemp.ActiveConnection = dataconn
InsertCursor.Open cmdTemp, , 1, 3
InsertCursor.AddNew
InsertCursor("BoardID") = boardID
InsertCursor("ParentID") = 0
InsertCursor("Child") = 0
InsertCursor("UserName") = UserName
InsertCursor("UserEmail") =UserEmail
InsertCursor("Topic") =Topic
InsertCursor("Body") =Body
InsertCursor("DateAndTime") =DateTimeStr
InsertCursor("hits") =0
InsertCursor("length")=strlength(body)
InsertCursor("rootID")=0
InsertCursor("layer")=1
InsertCursor("orders")=0
InsertCursor("ip")=ip
InsertCursor("Expression")=Expression
InsertCursor.Update
announceid=InsertCursor("AnnounceID")
InsertCursor("RootID")= announceid
InsertCursor.Update
-------------------------------------------------------------想将上述刚刚插入的记录中的编号取出然后在插入另一个字段然后更新数据集,出错!为什么??????????请高手帮忙,用的SQLSERVER数据库 OLEDB驱动

就是在SQLSERVER 2000中插入一个记录,然后在取出刚刚插入记录的自动编号字段的ID号,然后在将其赋值到另外一个字段,如何编写!上述代码错在何处?
...全文
79 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
mikecat888 2003-06-08
  • 打赏
  • 举报
回复
哦,知道如何附列名了.^_^,结贴
lqflsh 2003-05-30
  • 打赏
  • 举报
回复
不要给id赋值。他会自动增加的。
possible_Y 2003-05-30
  • 打赏
  • 举报
回复
插入数据时不能给自动编号的字段赋值
mikecat888 2003-05-30
  • 打赏
  • 举报
回复
没有主键,用@@identity只能取出空值亚!
tigerwen01 2003-05-30
  • 打赏
  • 举报
回复
取出刚刚插入记录的自动编号字段的ID号:@@identity
id=@@identity
sdliubo 2003-05-30
  • 打赏
  • 举报
回复
你的字段中有username 是系统关键字吧 换成[username]试试
mikecat888 2003-05-30
  • 打赏
  • 举报
回复
select max(identitycol) from bbs1
这样可以返回最后一个记录的编号,可是怎么用rs取?因为返回的字段没有列名.
mikecat888 2003-05-30
  • 打赏
  • 举报
回复
可不,自动编号字段当然不能赋值,只是它自动增长后取不出.
Reker熊 2003-05-30
  • 打赏
  • 举报
回复
自動編號不能賦值

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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