I am looping through a form that has me updating at least 14 records.
This is the script that I am using.
mySQL="UPDATE thaTable SET thaTable.ProdType = '" & DefaultType(m) & "', thaTable." & columnHdr & " = '" & DefaultEmp(M) & "' WHERE LineNum = " & Cint(m)& ""
Set Conn = Server.CreateObject("ADODB.Connection")
My question is, can/should I open and close the connection outside the for loop or does it matter?
Where is your FOR loop? If you execute the sql statement inside the loop, you need to open the connection. If the FOR loop is used to build the sql statement, you do not need to open the connection inside the loop.
What I did was create a sub routine that build the SQL. I loop through the form and get the values for each row of data. I then call the SQL statement. I run both and insert and update for each loop. I just wandered if it was better to leave the connection open as it loops through each row or should I open and close it within the loop?
Open the connection
For i = 1 to 14
a = request.form("a")
Set to nothing