日期:2014-05-17  浏览次数:20919 次

执行后,为何不能看到其自增长ID?
代码如下:
if   rs.eof   and   rs.bof   then
    sql= "insert   into   admin(admin_name,admin_pwd,admin_type,admin_sire)   values   ( ' "&username& " ', ' "&userpwd& " ', ' "&usertype& " ', "&admin_id& ") "
conn.execute(sql)    
adminiding   =   conn.execute( "select   @@identity ")(0)        

Response.write   adminiding   &   " <br> "
Response.End

end   if

为何打印不出来adminiding呢?为空,是怎么一回事,谢谢!

------解决方案--------------------
试试看
sql= "insert into admin(admin_name,admin_pwd,admin_type,admin_sire) values ( ' "&username& " ', ' "&userpwd& " ', ' "&usertype& " ', "&admin_id& ");select @@identity; "
------解决方案--------------------
最好使用select SCOPE_IDENTITY() as ID from [table]
select @@identity是全局变量