Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am accessing a field in a table,

Status
Not open for further replies.

princessk1

Programmer
Feb 28, 2002
74
CA
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top