I have a program, written as a service, that periodically opens all the files in a specific directoy, parses them out and sends the results to a stored procedure (SQL server is localhost) to be processed and stored away. Then it deletes the file and moves to the next. I've tried it a couple different ways and although it works fine, it seems pretty slow to me. I have a generic example of the way I'm currently doing it, was wondering if anyone sees any obvious traps?
An alternative I considered was to open a table, and push an entire file to it in batch mode, then fire off the stored procedure after the parsed file was finished. Not sure if that would really save in time though, and it would require a rewrite of the SP.
Code:
sub main
'dim variables, setup cnn object and open connection here
curFile = Dir(myPath)
do while curFile <> ""
'for every file I open I recreate the command and prm 'objects. I suppose I could do this once, globally, but 'this part of the process is really not slow
Set cmd = New ADODB.Command
cmd.ActiveConnection = cnn
cmd.CommandText = "spCountPoints"
cmd.CommandType = adCmdStoredProc
Set prmNode = cmd.CreateParameter("Node", _
adVarChar, adParamInput, 50, node)
cmd.Parameters.Append prmNode
'5 more prm's after this one
Open cuFile for input as #fileNum
Do while not EOF(FileNum)
'line input, and parse out the text here
prmNode.value = sNode
'5 more prm.values set here
'each line parsed in the file gets a sql call
cmd.execute
loop 'go to next line
close #filenum
kill curFile
set prm's & cmd = nothing
loop ' next file
'all files are done
cnn.close
set cnn = nothing
An alternative I considered was to open a table, and push an entire file to it in batch mode, then fire off the stored procedure after the parsed file was finished. Not sure if that would really save in time though, and it would require a rewrite of the SP.