Link to home
Start Free TrialLog in
Avatar of cdp092597
cdp092597

asked on

SQL Statement after ors.addneww

Hi,

I have some code which uses the following to add a new record

      ors2.addnew
      ors2.fields("sessionid") = session.sessionid
      ors2.update

after this, I run another sql statement using
"SELECT * FROM customers WHERE sessionid = " & session.sessionid
to get the unique ID of the record just added.

Trouble is, the second always returns an error because the database seemingly hasn't been updated from the first  statement (BOF and EOF are both true). If I run the second sql statement a few seconds later, it finds the new record no problem.

Is there any way I can fix this?

Many thanks,  Martin
Avatar of thunderchicken
thunderchicken

have you closed ors2?

ors2.close

also try...


"SELECT * FROM customers WHERE sessionid = '" & session.sessionid & "'"

instead

TC

ASKER CERTIFIED SOLUTION
Avatar of Marine
Marine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ors2.movelast
ors2.addnew
ors2("sessionid") = session.sessionid
ors2.update

"SELECT * FROM customers WHERE sessionid = " & session.sessionid
Avatar of Mark Franz
Can I make a suggestion... don't use table or column names that are the same as VB statements, calls, objects or events.  By naming the field sessionid you are just asking for trouble...
why not get the id before you update?

dim iUniquID

ors2.addnew
ors2("sessionid") = session.sessionid
iUniqueID = ors2("ID")
ors2.update



this is assuming that the name of the unique id field is "ID"
Avatar of cdp092597

ASKER

Comment accepted as answer