Insert data to two tables?

Results 1 to 2 of 2

Thread: Insert data to two tables?

  1. #1
    Join Date
    Dec 1969

    Default Insert data to two tables?

    Hello friends,<BR><BR> I have two tables both are inter-related. Structure of the tables are<BR><BR>Table1:<BR>---------<BR>trindno Autonumber (Primary Key)<BR>job_code Text<BR>Fact_code Text<BR>trdate Date/Time<BR><BR>Table2:<BR>---------<BR>indno Autonumber<BR>trindno Number (Ref key)<BR>Color_code Number<BR>Qty Number<BR><BR><BR>I can have many records with the same job_code and different fact_codes in the table1. Automatically details are stored in the table2.<BR><BR>My Code is like this,<BR><BR>conn.beginTrans<BR> strQry1="insert into table1(job_code,fact_code,trdate) values(" ...<BR> for i=0 to ubound(arrColorCode)-1<BR> strQry2="insert into table2(trindno,color_code,qty) values(x,y,z)"<BR> next<BR>conn.commitTrans<BR><BR>My problem is, how can i get the trindno from table1 to insert into table2. Coz bth inserts are doing at a time. B&#039;coz reference key ust have a value in primary key value.<BR><BR>Pls, give me the solution.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Insert data to two tables?

    Read the FAQ entitled "How do I get the ID of the record I just enterd?"<BR><BR>It&#039;s in one of the Database categories.<BR><BR>Craig.

Posting Permissions

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