+ Reply to Thread
Results 1 to 2 of 2

ODBConnection object vs. QueryTable object

  1. #1
    Registered User
    Join Date
    01-25-2014
    Location
    Minneapolis
    MS-Off Ver
    Professional Plus 2010
    Posts
    19

    Question ODBConnection object vs. QueryTable object

    Before August is over I want to successfully create a link between my spreadsheet and a database. At the moment it shall have to be a MySQL database because I can't seem to get the ODBC driver for Access working; that may be a separate thread.

    The only other time I've successfully used ODBC was in a previous job. I used CommBASIC, a dinky VB 3.0-derived scripting tool for manipulating a terminal emulator (Outside View) and it offered functions like SQLOpen(DSN="DinkyDSN", bla bla bla), SQLExecQuery, SQLRetrieve that would store your query results in a previously declared 2-dimensional array. Yay. (Before learning those functions I had been feeding everything into or from unacceptably primitive .csv files. Gross.)

    I'm still pretty much lost in the wilderness as far as even understanding the basics of how to do this with VBA. It looks like the two-dimensional array that CommBASIC used finds its counterpart in VBA's QueryTable object; but I'm also given to understand that I shall have to create an ODBCConnection object. I also notice that the ODBCConnection and QueryTable objects have very much (if not entirely?) the same methods and properties available.

    I can argue that Microsoft's own documentation doesn't even distinguish between the two objects!! In their Dev Center, on the page for the ODBCConnectionType.CommandText property (I'm not allowed to post a link) they say they're describing the .CommandText property of "A variable that represents an ODBCConnection object" and they give this here example:

    Please Login or Register  to view this content.
    ...wherein the variable is in fact a member of QueryTables!!

    Do I in fact need to declare an ODBCConnection object, or am I going to get away with the .Connection, .CommandType, .CommandText properties (and others) of a QueryTable?

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

    Re: ODBConnection object vs. QueryTable object

    Have you considered MS-Query?
    http://www.utteraccess.com/wiki/MS_Query

    Usually, no coding is required unless you develop a query so complicated that it cannot be displayed graphically. Then you can put the SQL in an excel table and use a couple of lines of VB Code to rewrite the command string on the fly.
    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. [SOLVED] Strange 'object invoked disconnected' then '1004 - object defined' errors
    By sumdumgai in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-14-2015, 09:48 PM
  2. Find in VBA finds first instance of similar object being searched but not exact object
    By xcelnovice101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2015, 01:10 PM
  3. [SOLVED] Object library invalid or contains references to object definitions that could not be foun
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-01-2015, 07:36 AM
  4. Replies: 0
    Last Post: 06-19-2014, 02:09 PM
  5. Replies: 12
    Last Post: 06-20-2012, 01:53 PM
  6. Replies: 3
    Last Post: 10-25-2011, 02:12 PM
  7. buggy macro 'intersect' of object of object'_global failed" when deleting rows
    By Kezwick in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-18-2011, 07:11 AM

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