Linking tables to SQL Server with DSN-less connections

Posted on 2005-05-05
Last Modified: 2008-06-15
I am trying to link tables to an Access 2002 mdb using a DNS-less connect string. I am a user on a network that uses Active Directory and I’m connected via VPN. Note: I have been able to successfully connect using a saved DSN. However, I want to use code to link tables with “DSN-less” connections. My vba code is:

DoCmd.TransferDatabase acLink, “ODBC Database”, ODBC;DRIVER=SQL Server;SERVER= Servername;UID=UserID;password=Password;DATABASE=dbname, acTable, sourcetablename, targetablename, , True

When I run the code, first I am prompted for Login ID and Password. Then I get the error msg:

Connection failed:
SQLState: ‘01500’
SQL Server Error: 0
[Microsoft][ODBC SQL Server Driver] Invalid connection string attribute
Connection failed:
SQL State: ‘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.
Question by:paulmcneil
    LVL 17

    Assisted Solution


     "DRIVER={SQL Server};Server='Servername';Database='dbname'....etc.

    here is a good site:
    LVL 50

    Accepted Solution

    Here's another one with pages specifically for DSN-less connections to a wide variety of databases:
    LVL 12

    Expert Comment

    Maybe you need to enclose this string in quotes:

    "ODBC;DRIVER=SQL Server;SERVER= Servername;UID=UserID;password=Password;DATABASE=dbname"

    Hope this helps!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now