Inserting into multiple tables

Results 1 to 2 of 2

Thread: Inserting into multiple tables

  1. #1
    Join Date
    Dec 1969

    Default Inserting into multiple tables

    I am new to this and having a simple problem. When I insert a new customer into the customer table (in access) and then need to insert an order corresponding to that customer, how do I get the CustomerID (unique key) to insert into the orders table.<BR><BR>I hope this is clear, using asp/ado/sql of course.

  2. #2
    Join Date
    Dec 1969

    Default RE: Inserting into multiple tables

    Okay....<BR>There must be two queries. From one you are inserting data into Customers table...and next query to insert data into Orders table. And you need CustomerID to insert record into Orders Table. Now there are few ways to get CustomerID.<BR><BR>One is like after inserting data into Customers table you can take any field from customers tabel using that recordset.<BR><BR>iCustomerID = RecordSet("Customer_ID")<BR><BR>Another way is you can write a COM Object to get a single field output from the executed query. But use COM Object only if you are going to use that extensively in your application. Otherwise first option is the best one.<BR><BR>I hope is this you want...<BR><BR>Thx<BR>Ani.

Posting Permissions

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