Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Objects in ASP 2

Status
Not open for further replies.

vatik

Technical User
Jul 13, 2001
20
0
0
US
After adding a new record using the ADO recordset, I cannot get the id (autonumbered in access2000 database) to return a value. I have looked through code snippets and it seems to work for them. If anyone knows of any issues concerning this, or an alternate way to accomplish this, it would be appreciated.

Here is the code:
---------------------------------------------
<%

Dim conn
Dim sql

set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.open &quot;ttek&quot;,&quot;&quot;,&quot;&quot;
set session(&quot;ttek_conn&quot;) = conn

sql = &quot;SELECT * FROM [RMA] WHERE [ID]=0&quot;
set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open sql,conn,3,3

rs.AddNew
rs(&quot;rma#&quot;) = CStr(1234)
rs.Update

Response.write(&quot;Not Working Still&quot; & rs.Fields(&quot;id&quot;).value)

rs.Close
set rs=Nothing
%>
 
Try issuing a requery after rs.Update

eg:

rs.update
rs.requery

maybe that will get it working for you

hth
leo leo
 


vatik,

You can &quot;trick&quot; the database call by moving to the last record added.

rs.AddNew
rs(&quot;rma#&quot;) = CStr(1234)
rs.Update
rs.Movelast
Response.write &quot;Last ID: &quot; & rs(&quot;id&quot;)

fengshui1998

 
That did the trick, I never thought of that. Thanks guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top