conn.begintrans'//加入事务控制机制,防止出现数据不一至
conn.execute("insert into dv_topic(title,boardid,postusername,postuserid,posttable) values('"&title&"',"&boardid&",'"&fn_UserName(userid)&"',"&userid&",'dv_bbs1')")
max_addbbsID=conn.execute("select @@IDENTITY ")(0)'//获取当前插入记录的ID值
conn.execute("insert into dv_bbs1(parentid,boardid,username,topic,body,DateAndTime,rootid,orders) values(0,"&boardid&",'"&fn_UserName(userid)&"','"&title&"','"&body&"','"&now()&"',"&max_addbbsID&",0)")
if conn.errors.count>0 then
conn.rollbacktrans
err.clear()
response.end()
else
conn.committrans'//提交事务
end if
conn.execute("insert into dv_topic(title,boardid,postusername,postuserid,posttable) values('"&title&"',"&boardid&",'"&fn_UserName(userid)&"',"&userid&",'dv_bbs1')")
max_addbbsID=conn.execute("select @@IDENTITY ")(0)'//获取当前插入记录的ID值
conn.execute("insert into dv_bbs1(parentid,boardid,username,topic,body,DateAndTime,rootid,orders) values(0,"&boardid&",'"&fn_UserName(userid)&"','"&title&"','"&body&"','"&now()&"',"&max_addbbsID&",0)")
if conn.errors.count>0 then
conn.rollbacktrans
err.clear()
response.end()
else
conn.committrans'//提交事务
end if