Number_Nineteen
07-07-2004, 06:56 PM
Hi All,
I am attempting to write a function that inserts about 5000 or more records at a time into an Access database table. I am reading a comma-delimited file to get the values, and then inserting them using an standard "FOR" loop. Each time I loop, I run a SQL Insert. The problem is, this is sooooo SLOOOOOW... not to mention poor design. Often the script times out. Unfortunately, I don't know any other method. Also, I must use Access. There is no SQL Server option, which would help, but there is also no load on this app... no concurrent users.
Any ideas?
My code (lots of other stuff, but note the 'INSERT INTO' below):
SplitValues = split(SplitLines(counter), ",")
For values = 0 to ubound(SplitValues)
SUAVLookup = "SELECT * FROM SiteUserAttributeValue WHERE SiteID = " & session("siteID") & " AND UserID like '" & UID & "' AND AttributeName like '" & SplitCols(values) & "' ORDER BY USerID ASC"
Cmd.CommandText = SUAVLookup
Set Rs = Cmd.Execute
SUAVCount = 0
While not Rs.EOF
SUAVCount = SUAVCount + 1
Rs.MoveNext
Wend
if SUAVCount = 0 then
SUAV = "INSERT INTO SiteUserAttributeValue (SiteID,UserID,AttributeName,ValueChar200) VALUES ("
SUAV = SUAV & "'" & session("siteID") & "','" & UID & "','" & SplitCols(values) & "','" & SplitValues(values) & "')"
Cmd.CommandText = SUAV
Set Rs = Cmd.Execute
'response.write SUAV & "<br>"
end if
Next
I am attempting to write a function that inserts about 5000 or more records at a time into an Access database table. I am reading a comma-delimited file to get the values, and then inserting them using an standard "FOR" loop. Each time I loop, I run a SQL Insert. The problem is, this is sooooo SLOOOOOW... not to mention poor design. Often the script times out. Unfortunately, I don't know any other method. Also, I must use Access. There is no SQL Server option, which would help, but there is also no load on this app... no concurrent users.
Any ideas?
My code (lots of other stuff, but note the 'INSERT INTO' below):
SplitValues = split(SplitLines(counter), ",")
For values = 0 to ubound(SplitValues)
SUAVLookup = "SELECT * FROM SiteUserAttributeValue WHERE SiteID = " & session("siteID") & " AND UserID like '" & UID & "' AND AttributeName like '" & SplitCols(values) & "' ORDER BY USerID ASC"
Cmd.CommandText = SUAVLookup
Set Rs = Cmd.Execute
SUAVCount = 0
While not Rs.EOF
SUAVCount = SUAVCount + 1
Rs.MoveNext
Wend
if SUAVCount = 0 then
SUAV = "INSERT INTO SiteUserAttributeValue (SiteID,UserID,AttributeName,ValueChar200) VALUES ("
SUAV = SUAV & "'" & session("siteID") & "','" & UID & "','" & SplitCols(values) & "','" & SplitValues(values) & "')"
Cmd.CommandText = SUAV
Set Rs = Cmd.Execute
'response.write SUAV & "<br>"
end if
Next