princessk1
Programmer
I am accessing a field in a table, changing the format and then updating the field with the new format. I am getting a 'Timeout Expired' error when it is updating the field with the new format. I have tried increasing the
cmd.commandTimeout but it isn't working. Does anyone know any other reasons why scripts timeout?
Here is my code:
Set cnn = CreateObject("ADODB.Connection"
Set rs = CreateObject("ADODB.Recordset"
Set cmd = CreateObject("ADODB.Command"
SQLServerConnect = "Driver=SQL Server;" & _
"Server=LWIDWDRV;" & _
"Database=LWIDWH01;" & _
"PWD=;" + passwd & _
"UID=" + loginID
cnn.Open SQLServerConnect
cmd.ActiveConnection = cnn
cmd.commandTimeout = 1000
SQL = "SELECT Order_ID,Summary FROM sales_trans_OrdMain"
cmd.CommandText = SQL
rs.Open cmd, , adOpenForwardOnly
While Not rs.EOF
pos = InStr(1, rs.Fields("Summary".Value, "Temp"
If pos = 1 Then
pos2 = InStr(1, rs.Fields("Summary".value, " "
strg = Mid(rs.Fields("Summary".value, pos, pos2-1)
strg = trim(strg)
orderid = trim(rs.Fields("Order_ID".Value)
SQL = "Update sales_trans_ordmain set summary = '" & strg & "' where Order_ID = '" & orderid & "'"
cmd.CommandText = SQL
cmd.Execute
Else
pos1 = InStr(1,rs.Fields("Summary".value, ":"
strg = Mid(rs.Fields("Summary".value, pos1+1)
strg = trim(strg)
SQL = "Update sales_trans_ordmain set summary = '" & strg & "' where Order_ID = '" & orderid & "'"
cmd.CommandText = SQL
cmd.Execute
End If
rs.MoveNext
Wend
End Sub
cmd.commandTimeout but it isn't working. Does anyone know any other reasons why scripts timeout?
Here is my code:
Set cnn = CreateObject("ADODB.Connection"
Set rs = CreateObject("ADODB.Recordset"
Set cmd = CreateObject("ADODB.Command"
SQLServerConnect = "Driver=SQL Server;" & _
"Server=LWIDWDRV;" & _
"Database=LWIDWH01;" & _
"PWD=;" + passwd & _
"UID=" + loginID
cnn.Open SQLServerConnect
cmd.ActiveConnection = cnn
cmd.commandTimeout = 1000
SQL = "SELECT Order_ID,Summary FROM sales_trans_OrdMain"
cmd.CommandText = SQL
rs.Open cmd, , adOpenForwardOnly
While Not rs.EOF
pos = InStr(1, rs.Fields("Summary".Value, "Temp"
If pos = 1 Then
pos2 = InStr(1, rs.Fields("Summary".value, " "
strg = Mid(rs.Fields("Summary".value, pos, pos2-1)
strg = trim(strg)
orderid = trim(rs.Fields("Order_ID".Value)
SQL = "Update sales_trans_ordmain set summary = '" & strg & "' where Order_ID = '" & orderid & "'"
cmd.CommandText = SQL
cmd.Execute
Else
pos1 = InStr(1,rs.Fields("Summary".value, ":"
strg = Mid(rs.Fields("Summary".value, pos1+1)
strg = trim(strg)
SQL = "Update sales_trans_ordmain set summary = '" & strg & "' where Order_ID = '" & orderid & "'"
cmd.CommandText = SQL
cmd.Execute
End If
rs.MoveNext
Wend
End Sub