+ Reply to Thread
Results 1 to 5 of 5

odbcconnection error handle

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    4

    odbcconnection error handle

    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

  2. #2
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: odbcconnection error handle

    can you please provide the exact error code as it looks like your code is OK
    error code's table : http://msdn.microsoft.com/en-us/libr...sql.80%29.aspx

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: odbcconnection error handle

    Thanks for you reply.

    Error message:
    Connection failed:
    SQLState '01000'
    SQL Server Error: 53
    [Microsoft][ODBC][SQL Server Driver][DBNETLIB]ConnectionOpen(Connect())
    Connection failed:
    SQLState: '08001'
    SQL Server Error: 17
    [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied
    The idea is not to fix the problem but to show with a friendly message what to do,i.e.,
    msgbox("Please connect to the internet")

  4. #4
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: odbcconnection error handle

    ah ok in that case the GoTo i used in below exampel works fine

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-27-2012
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: odbcconnection error handle

    I did that and I still receive the error same error message. After the error message appears the message with "sorry there was an issue".

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1