Re: Inserting multiple records
From: dave (none_at_invalid.com)
Date: 10/31/04
- Previous message: Bob Barrows [MVP]: "Re: Inserting multiple records"
- In reply to: Bob Barrows [MVP]: "Re: Inserting multiple records"
- Next in thread: Bob Barrows [MVP]: "Re: Inserting multiple records"
- Reply: Bob Barrows [MVP]: "Re: Inserting multiple records"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Nov 2004 06:32:52 +1300
Thanks Bob, yes using 2k & Jet4
Not quite sure I follow yet, but using that logic, and assuming I have an
array of values, how would this go?
sSQL = "Insert Into table (A,B,C) Union All Select
'valA','valB','valC','valA1','valB1','valC1','valA2','valB2','valC2'
My inputed values get delimited as above? (All text)
Cheers
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OGcHLZ2vEHA.1296@TK2MSFTNGP10.phx.gbl...
> dave wrote:
> > Using Access, is there an easier, or less intensive way of inserting
> > many records into the database at the same time?
> >
> > eg - insead of doing this:
> >
> > objConn.Execute("Insert INTO .....")
> > objConn.Execute("Insert INTO .....")
> > objConn.Execute("Insert INTO .....")
> > objConn.Execute("Insert INTO .....")
> > objConn.Execute("Insert INTO .....")
> > objConn.Execute("Insert INTO .....")
> >
> > Is there a faster / better way?
>
> You can turn it into a single call to the database by constructing a union
> query. The following example works with A2K and higher (Jet4). If you are
> using an earlier version, a) you should have told us and b) there is a
> workaround:
>
> dim sSQL, sUnion
> sSQL = "Insert Into table (col1, ..., colN) "
> 'start loop
> 'populate value variables
> if len(sSelect) = 0 then
> sUnion="Select " & val1 & ... & valN
> else
> sUnion= sSelect & " Union All Select " & val1 & ... & valN
> end if
> 'end loop
> sSQL = sSQL & sUnion
> objConn.Execute sSQL,,1
>
> HTH,
> Bob Barrrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
- Previous message: Bob Barrows [MVP]: "Re: Inserting multiple records"
- In reply to: Bob Barrows [MVP]: "Re: Inserting multiple records"
- Next in thread: Bob Barrows [MVP]: "Re: Inserting multiple records"
- Reply: Bob Barrows [MVP]: "Re: Inserting multiple records"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|