Insert into 后获得自动插入的id(select @@identity)
刚才看到博客园一个朋友写的关于
//找出刚刚插进去的id值
DataTable dt = helper.getDataTable("select top 1 msg_id from TB_MESSAGE_BOARD order by MSG_TIME desc ");
DataTable dt = helper.getDataTable("select top 1 msg_id from TB_MESSAGE_BOARD order by MSG_TIME desc ");
感觉欠妥,特别并发的时候。自己搜索了下,以备后用.
当运行完插入语句后,执行select @@identity就可得到自动生成的id |