Hi

I already search the forum and in google but I cannot find any way to handle with the network error messages when i tried to update my table. It will work well if I have connection to the server.

The use "On error goto exitOnerror" is not working. The odbc error message still appears.



Dim Conn As String

Conn = "ODBC;DRIVER=SQL Server;" & _
"SERVER=<server>;" & _
"UID=<user>;" & _
"PWD=<pass>;" & _
"APP=Microsoft Office 2010;" & _
"WSID=<Host>;" & _
"DATABASE=<database>"

With ActiveWorkbook.Connections("SQLCommand").OdbcConnection
.BackgroundQuery = True
.CommandText = Sheets("SQLString").Range("A2").Value
.CommandType = xlCmdSql
.Connection = Conn
.RefreshOnFileOpen = False
.SavePassword = True
.SourceConnectionFile = ""
.SourceDataFile = ""
.ServerCredentialsMethod = xlCredentialsMethodIntegrated
.AlwaysUseConnectionFile = False
End With
With ActiveWorkbook.Connections("SQLCommand")
.Name = "SQLCommand"
.Description = ""
End With


' ---------------------------------
' --------- REFRESH ODBC ----------
' ---------------------------------

ActiveWorkbook.Connections("SQLCommand").Refresh
Application.ScreenUpdating = True
I appreciate any help in advance.

Thank you.
Jose