+ Reply to Thread
Results 1 to 2 of 2

Trying to establish new data connection to SQL database but it keeps failing.

  1. #1
    Registered User
    Join Date
    04-30-2020
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    365
    Posts
    4

    Trying to establish new data connection to SQL database but it keeps failing.

    I have numerous legacy files that pull data directly from our ERP's SQL server. I work from home and I am able to refresh the data as long as I am connected to the company VPN. I am trying to put together one of these files myself and the connection fails every time. I have tested my SQL code by swapping it into the existing Command Text box in the connection definition window. My SQL code works.

    However, for the file I am trying to build I want to pull the data into Power Query first before loading it as a table in the workbook.

    For the new connection settings I am using the exact same server, database, username, and password values that exist in the Connection String in the legacy files but there are other values that I am not given the option of entering when creating a new connection (prefetch, connectioncache, driver, etc.).

    I am always left with the same error message: "Details: Microsoft SQL: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)"

    Is there an advanced "New Connection" option somewhere that lets me add these additional settings? Is there something else I am missing?

    Capture2.PNG

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: Trying to establish new data connection to SQL database but it keeps failing.

    I have not worked with SQL databases, but I have worked with other databases.

    The secret is to download the connection string. This is usually a semicolon delimited string. You should be able to pick out where the piece of information you want resides. Use the SPLIT command in VBA to replace the element you want and rejoin the string with JOIN.

    I've done this to connect to Oracle, Access and Excel.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 11-16-2019, 09:05 AM
  2. SQL Connection code in VBA is failing
    By Phixer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-31-2014, 02:59 PM
  3. Replies: 2
    Last Post: 07-05-2013, 09:37 AM
  4. DDE Connection failing
    By Jenn68 in forum Word Formatting & General
    Replies: 3
    Last Post: 06-01-2012, 08:03 AM
  5. Replies: 0
    Last Post: 03-23-2011, 03:23 AM
  6. Problem establish connection to an excel worksheet via DDE from DDE client.
    By najsel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2011, 03:41 AM
  7. Word to Excel Merge connection failing
    By techexpressinc2 in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2011, 01:28 PM

Tags for this Thread

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