how to get row just inserted

Discussion in 'ASP General' started by middletree, Dec 12, 2003.

  1. middletree

    middletree Guest

    ASP 3 and Access 2000. I have a page which enters a row into a table, and
    then enters some other info into another table. Problem is, I need to do the
    first one, then obtain the PK, which is an Autonumber, so I can enter it
    into the other table.

    I know how to do this in SQL Server with identity columns, but this is
    Access. (I know Access is not very good, but I have to use it for this
    church project.)

    Here's my code:

    strFName = Replace(Trim(Request.Form("FName")),"'","''")
    etc.

    strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[etc]"
    Set objConnection = Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionString = strConnection
    objConnection.Open
    strSQL = "INSERT INTO Personal(etc) "
    strSQL = strSQL & "VALUES(etc) "
    objConnection.Execute strSQL

    So now I need to do a SELECT from the Personal table, then enter that into
    the table which consists of 2 fields, both of which are FK's for other
    tables (this table was put in to resolve a many-to-many relationship)

    FWIW, I'm doing this in a loop; that is, I have a variable number of
    checkboxes, and for each one checked by the user, I'll have to insert a row
    into this 2nd table. One one entry into the first table, though.

    Any help would be appreciated.
     
    middletree, Dec 12, 2003
    #1
    1. Advertising

  2. middletree

    Ray at Guest

    "middletree" <> wrote in message
    news:...
    > ASP 3 and Access 2000. I have a page which enters a row into a table, and
    > then enters some other info into another table. Problem is, I need to do

    the
    > first one, then obtain the PK, which is an Autonumber, so I can enter it
    > into the other table.


    http://www.aspfaq.com/show.asp?id=2174

    Ray at home
     
    Ray at, Dec 12, 2003
    #2
    1. Advertising

  3. middletree

    middletree Guest

    Dang! I usually go to aspfaq first, but didn't do it this time. Thanks!


    "Ray at <%=sLocation%>" <myFirstNameATlane34dotKOMM> wrote in message
    news:...
    >
    > "middletree" <> wrote in message
    > news:...
    > > ASP 3 and Access 2000. I have a page which enters a row into a table,

    and
    > > then enters some other info into another table. Problem is, I need to do

    > the
    > > first one, then obtain the PK, which is an Autonumber, so I can enter it
    > > into the other table.

    >
    > http://www.aspfaq.com/show.asp?id=2174
    >
    > Ray at home
    >
    >
     
    middletree, Dec 12, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=

    Best way to get ID of inserted row??

    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Nov 16, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,905
    Deepak
    Nov 17, 2004
  2. lucky
    Replies:
    0
    Views:
    516
    lucky
    Jan 12, 2005
  3. Dan Sikorsky
    Replies:
    2
    Views:
    11,500
    SiliconViper
    Apr 30, 2009
  4. Patrick.O.Ige
    Replies:
    0
    Views:
    528
    Patrick.O.Ige
    Oct 31, 2007
  5. D
    Replies:
    0
    Views:
    220
Loading...

Share This Page