前题条件:id 为自动增长型
set @id=@@identity

解决方案 »

  1.   

    是自动编号的ID吗?那就这样
    select @@identity
      

  2.   

    对了,是在ASP里面啊(ASP操作 MS SQL SERVER ,关外一个客户用老掉牙的系统,让我改点东东)
    ID是自动编号
    记录插进数据库了,怎么用ASP立即获得本记录的ID? 
      

  3.   

    rdtemp.Open "Select @@identity as Fid", pData, adOpenStatic, adLockReadOnly
      

  4.   


    rs.open "select * from table1 where id is null",conn,1,3
    cursorLocation=2
    rs.addnew
    rs("name")="dxy"
    ..
    rs.update
    id_new=rs("id")
    rs.close
      

  5.   

    我是这样写的,可是运行 有错,错在哪里呢?sql="SET NOCOUNT ON;insert into t_lesson_info(lessonbh,itemnotes,startdate,enddate,lessontime,"
    sql=sql & "teacher,lessonway,testway,lessonbook,notes,personnum,score,inputtime) values ("
    sql=sql & "'" & lessonbh & "','" & itemnotes & "','" & startdate & "','" & enddate & "','" & lessontime & "','"
    sql=sql & teacher & "','" & lessonway & "','" & testway & "','" & lessonbook & "','" & notes & "','"
    sql=sql & personnum & "','" & score & "','" & submittime & "');SELECT @@IDENTITY;SET NOCOUNT OFF"
    set rooidRS=conn.execute sql
                If rooidRS.EOF Then Response.Write "NO the item!" : Response.End
       lesson_id=rooidRS("0")