+ Reply to Thread
Results 1 to 4 of 4

VBA to connect to Database using ODBC data source

  1. #1
    Registered User
    Join Date
    03-15-2010
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    6

    VBA to connect to Database using ODBC data source

    I like to connect to a SQL 2005 database from my Excel VBA project.

    I have setup a ODBC data source called MSSQLDEV that connects to the SQL 2005 database

    How do I build the connection string using this ODBC data source to connect to the SQL 2005?
    thanks.

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: VBA to connect to Database using ODBC data source

    A good reference for connection strings is:

    http://www.connectionstrings.com/sql-server-2005


    It will list all the variations

    hope this helps


    click on the * Add Reputation if this was useful or entertaining.

  3. #3
    Registered User
    Join Date
    03-25-2010
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: VBA to connect to Database using ODBC data source

    The technique I used is by creating a udf file. Double click it and the Microsoft Data Link Wizard will start. Specify your connection and test it. Then open the udf file in say notepad to inspect the connection string.

    If you want an easy way of connecting to your database (not only through ODBC) you can have a look at my SQL*XL tool. It integrates fully into Excel and allows full featured database access. There is a connection wizard in SQL*XL that will try many different connection strings. There is the possibility to inspect or edit the connection string. I hope you find it useful.

    SQL*XL homepage
    www.oraxcel.com/projects/sqlxl

    Best regards, Gerrit-Jan Linker
    Developer of SQL*XL

  4. #4
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388

    Re: VBA to connect to Database using ODBC data source

    Quote Originally Posted by qed59 View Post
    I like to connect to a SQL 2005 database from my Excel VBA project.

    I have setup a ODBC data source called MSSQLDEV that connects to the SQL 2005 database

    How do I build the connection string using this ODBC data source to connect to the SQL 2005?
    thanks.
    The ODBC DSN you created should contain all the information needed to connect to your database. It would be used like this:
    Please Login or Register  to view this content.

+ 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