Jonathan Rynd
2004-05-20 22:01:31 UTC
In VBA (Excel), connecting to MS SQL Server
We have some code that creates an ADODB recordset. We set
Public glbConn As ADODB.Connection
Set glbConn = New ADODB.Connection
glbConn.Provider = "MSDASQL"
strConn = "DSN=" & kDBKMDSN & ";UID=" & kDBKMUser & ";PWD=" & _
kDBKMPass & ";"
glbConn.ConnectionString = strConn
glbConn.Open
Set mRS = New ADODB.Recordset
With mRS
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.ActiveConnection = glbConn
End With
and then in a loop we call
With mRS
.Source = strSQL
.Open
' more stuff
.Close
End With
The problem is that, on some computers but not others, the call to .Open
hangs -- it takes forever. The only way to recover is to break the
program (ctrl-break or esc), click debug, and then press F5. That makes
things start working again. Without doing that it hangs forever.
This hang does not take place when the code is stepped through using F8.
- How can I diagnose this? What other information would be helpful?
We have some code that creates an ADODB recordset. We set
Public glbConn As ADODB.Connection
Set glbConn = New ADODB.Connection
glbConn.Provider = "MSDASQL"
strConn = "DSN=" & kDBKMDSN & ";UID=" & kDBKMUser & ";PWD=" & _
kDBKMPass & ";"
glbConn.ConnectionString = strConn
glbConn.Open
Set mRS = New ADODB.Recordset
With mRS
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.ActiveConnection = glbConn
End With
and then in a loop we call
With mRS
.Source = strSQL
.Open
' more stuff
.Close
End With
The problem is that, on some computers but not others, the call to .Open
hangs -- it takes forever. The only way to recover is to break the
program (ctrl-break or esc), click debug, and then press F5. That makes
things start working again. Without doing that it hangs forever.
This hang does not take place when the code is stepped through using F8.
- How can I diagnose this? What other information would be helpful?