Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert imto more than 1 table 2

Status
Not open for further replies.

discusmania

IS-IT--Management
Oct 24, 2000
158
AP
hi guys....
Can i insert a record into more than 1 table.if so how?

thanks alot
Ron
 
Hi,

You can use a record as much as you pleased! After you fill a table you can always order the record set to go to the first position and start all over. That also depend how didi you opened the database. Try <recordset>.movefirst to go the first position.

Regards,
Luís Silva
 
Ron wants to add a record to more than 1 table with 1 sql instruction... I think this is not possible (but i'm no SQL expert).
So i think you need to write a Stored Procedure for this.
Maybe a Trigger is an alternative, eg when you want to keep a history of changes.

br
Gerard
(-:
 
Here's how I insert into two separate tables. Hope this helps...

<%

SQL1=&quot;INSERT INTO table1(field1, field2, field3) Values (&quot;&_
&quot;'&quot;& request.form(&quot;field1&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field2&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field3&quot;)& &quot;')&quot;



SQL2=&quot;INSERT INTO table2(field4, field5, field6) Values (&quot;&_
&quot;'&quot;& request.form(&quot;field4&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field5&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field6&quot;)& &quot;')&quot;




Dim myRS1
set myRS1=server.createobject(&quot;adodb.recordset&quot;)
myRS1.open sql, &quot;dsn=mydsn&quot;



Dim myRS2
set myRS2=server.createobject(&quot;adodb.recordset&quot;)
myRS2.open sql, &quot;dsn=mydsn&quot;

%>
Tony
:)
 
That post is hard to read, here you go again

<%

SQL1=&quot;INSERT INTO table1(field1, field2, field3) Values (&quot;&_
&quot;'&quot;& request.form(&quot;field1&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field2&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field3&quot;)& &quot;')&quot;



SQL2=&quot;INSERT INTO table2(field4, field5, field6) Values (&quot;&_
&quot;'&quot;& request.form(&quot;field4&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field5&quot;)& &quot;', &quot; &_
&quot;'&quot;& request.form(&quot;field6&quot;)& &quot;')&quot;




Dim myRS1
set myRS1=server.createobject(&quot;adodb.recordset&quot;)
myRS1.open sql, &quot;dsn=mydsn&quot;



Dim myRS2
set myRS2=server.createobject(&quot;adodb.recordset&quot;)
myRS2.open sql, &quot;dsn=mydsn&quot;
%>
Tony
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top