Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: help in add multiple records


Message #1 by "Chris Ullman (List moderator)" <chrisu@w...> on Thu, 24 Aug 2000 17:30:37
Forwarded message...



-----Original Message-----

From: Tham Weng San [mailto:thamws@a...]

Sent: 23 August 2000 05:36



i need somebody help. i would like to add multiple records in a table at 

the same time (using ms.access and asp).

That means more than 1 rows of records i want to add in at one time in the 

same table.

Message #2 by Imar Spaanjaars <Imar@S...> on Thu, 24 Aug 2000 18:35:03 +0200
One way to do this, is to execute a SQL statement inside a loop.

In SQL server you could add lot's of SQL statements together by seperating 

them with a vbCRLF and then execute that statement at once, but that 

doesn't seem to work in Access (see previous posts on this list).



So try something like this:



<something like this>

Dim cmdInsert

Set cmdInsert= Server.CreateObject("ADODB.Command")

cmdInsert.ActiveConnection = sYourConnectionStringOroYourConnectionObjectHere



for i = 0 to 100

         sSQL = "INSERT INTO myTABLE (ID, Name) VALUES (" & i & ", 'Value_" 

& i & "')"

         cmdInsert.CommandText = sSQL

         cmdInsert.Execute

next



(Set) cmdInsert.ActiveConnection = Nothing

Set cmdInsert = Nothing

</something like this>



This will insert multiple records, their values determined by i.



Hope this helps.



Imar







At 05:30 PM 8/24/2000 +0000, you wrote:

>Forwarded message...

>

>-----Original Message-----

>From: Tham Weng San [mailto:thamws@a...]

>Sent: 23 August 2000 05:36

>

>i need somebody help. i would like to add multiple records in a table at

>the same time (using ms.access and asp).

>That means more than 1 rows of records i want to add in at one time in the

>same table.

>

>---

>You are currently subscribed to asp_databases






Message #3 by "Ken Schaefer" <ken@a...> on Mon, 28 Aug 2000 17:12:33 +1000
You can't.



Each INSERT INTO SQL statement adds a single row to your database.



You need to execute several INSERT INTO statements on the same page.



Cheers

Ken



> -----Original Message-----

> From: Tham Weng San 

> Sent: 23 August 2000 05:36

>

> i need somebody help. i would like to add multiple records in a table at

> the same time (using ms.access and asp).

> That means more than 1 rows of records i want to add in at one time in the

> same table.






  Return to Index