Is this possible.

Results 1 to 3 of 3

Thread: Is this possible.

  1. #1
    Join Date
    Dec 1969

    Default Is this possible.

    Is it possible to create a record and then immediately select the record that you just created.

  2. #2
    Join Date
    Dec 1969

    Default Yes; access or sql server?

    In sql server, you can reference the "just-added" autonumber by @@IDENTITY, in access, I dont know if there is a way, you could still do a MAX(autonumber_field_ and get the id...

  3. #3
    Join Date
    Dec 1969

    Default RE: Is this possible.

    Perhaps check out the following:<BR><BR> : ASP FAQS : Databases, General<BR>How do I get the record number of a just added record, using an Access database table? by Bill Wilkinson - 11/3/2000 <BR><BR>RS.Open tableName, yourAlreadyOpenConnection, adOpenKeySet, adLockOptimistic, adCmdTable<BR>RS.AddNew<BR>RS("field1") = value1<BR>RS("field2") = value2<BR>...<BR>RS("fieldN") = valueN<BR>RS.Update<BR>idOfAddedRecord = RS("nameOfAutonumberField")<BR>You may substitute adLockPessimistic for adLockOptimistic, as you wish. But the adOpenKeyset is critical.<BR>[JPS Note: I noticed that the adOpenKeyset instead of adOpenForwardOnly cursor type may not be needed for a DSN-less connection but definitely IS needed for a DSN connection so might as well always use it if adding a new record and will be wanting to get the autonumber.]<BR><BR>Best regards,<BR>-Paul<BR>Web Database Developer<BR><BR><BR>

Posting Permissions

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