Trying to grab identity value after doing rs.updat

Results 1 to 2 of 2

Thread: Trying to grab identity value after doing rs.updat

  1. #1
    Chad Lich Guest

    Default Trying to grab identity value after doing rs.updat

    We are using SQL 7.0 sp1 on a IIS 5.0 server. We are trying to grab the ID value of a incrementing field in the table after we write all the data to it. Our problem is the value will not come back. Our guess is the cursor or lock type, but everything we try doesn&#039t give us the proper solution. We didn&#039t have a problem doing this with SQL 6.5? <BR><BR>Here is a sample of the code: <BR><BR>&#060;% <BR>Set conn = Server.CreateObject("ADODB.Connection") <BR>Conn.Open "TestingTable","sa","" <BR>sql = "Select * from Testingtable_Page_Pref" <BR>Set rs = Server.CreateObject("ADODB.Recordset") <BR>rs.Open sql, conn, 3, 3 <BR><BR>rs.addnew <BR><BR>rs("variable1") = variable1 <BR>rs("variable2") = variable2 <BR><BR>rs.update <BR><BR>pageid = rs("pageid") %&#062; <BR><BR>PAGE ID = &#060;%=PAGEID%&#062; &#060;% <BR><BR>rs.close <BR>set rs = nothing %&#062; <BR>

  2. #2
    Neil Popham Guest

    Default RE: Trying to grab identity value after doing rs.u

    i use ms access, but i&#039m not sure that&#039s relevant.<BR><BR>try the following<BR><BR>&#062; rs.update<BR>&#062; rs.MoveLast<BR>&#062; pageid = rs("pageid")<BR><BR>i have been told that the .MoveLast is uneccesary (when i previously posted a scenario such as yours). HOWEVER i do appear to need it cos i did it the other day and tried leaving it out. i just read this morning that using ADO and adLOckOptimistic it is necessary to move OFF the current record for it to update - which seems to proove me right (don&#039t ya just love that?)<BR><BR>hope it works for you<BR><BR>neil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts