Results 1 to 9 of 9

Thread: Connecting to MySQL from ADO in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    10

    Connecting to MySQL from ADO in VB

    I am trying to connect to an online MySQL database from VB6 using ADO
    and I'm getting the following error. "data source name not found and no default driver specified"

    here's the code I'm using to try to connect.

    Code:
            Set conn = New ADODB.Connection
        Set rs = New ADODB.Recordset
        connectionstring = "Driver={MySQL ODBC 5.1 Driver};Data Source=URL,3306;Database=DBNAME;User=USERID; Password=PASS;Option=3;"
        conn.Open connectionstring
        rs.Open "SELECT * FROM card_prices", conn
    no doubt its simply my inexperience with this type of connection. I have plenty of experience with MySQL but none with these connection string jiggys.

    P.S. I've tried downloading the MySQL ODBC 5.1 Driver and installed it but no effect. Do I have to install the version matching my system or the one matching the server?
    Last edited by markmercer; Jul 9th, 2012 at 02:46 PM.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Connecting to MySQL from ADO in VB

    http://www.connectionstrings.com/mysql

    It's uid and pwd.... not User and Password....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    10

    Re: Connecting to MySQL from ADO in VB

    that's irrelevant. I've tried it both ways, same error.

    http://www.connectionstrings.com/mysql#p31

    the error i'm getting is not to do with those fields.

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Connecting to MySQL from ADO in VB

    Quote Originally Posted by markmercer View Post
    P.S. I've tried downloading the MySQL ODBC 5.1 Driver and installed it but no effect. Do I have to install the version matching my system or the one matching the server?
    The driver on your machine must match what you are using in your connection string.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    10

    Re: Connecting to MySQL from ADO in VB

    ok thats the one I have installed

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Connecting to MySQL from ADO in VB

    Quote Originally Posted by markmercer View Post
    that's irrelevant. I've tried it both ways, same error.

    http://www.connectionstrings.com/mysql#p31

    the error i'm getting is not to do with those fields.
    If you look at the strings at that link none of them match what you have

    you have Data Source= where they all use Server= instead

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    10

    Re: Connecting to MySQL from ADO in VB

    Quote Originally Posted by DataMiser View Post
    If you look at the strings at that link none of them match what you have

    you have Data Source= where they all use Server= instead
    well your right.
    I HAD used examples directly off that site but that was before I installed the driver. now I have tried this one:

    Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;

    and I get a different error (to me that means I'm making progress).
    the error is "Can't connect to MySQL server on myServerAddress"

    I wonder if I have to submit an address other than the root domain. Have any of you guys ever done this with a domain managed by Cpanel?
    Last edited by markmercer; Jul 10th, 2012 at 06:10 AM.

  8. #8
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Connecting to MySQL from ADO in VB

    So you're trying to access a mySQL database that is on a web server somewhere? That presents a whole new set of problems. You';ll need to check with the host... a lot of them (if they are any good) only make their databases available from within their domain... and not directly accessable to the outside world. If that's the case, then you'll need create something that acts as a web service and can be put onto the webserver, take requests, and return data.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  9. #9

    Thread Starter
    New Member
    Join Date
    Jun 2012
    Posts
    10

    Re: Connecting to MySQL from ADO in VB

    I am a web developer, and I've been using this host for many years now. I know that the server will allow incoming connections because in the past I've opened a connection to it from another site. But I wouldn't be surprised if it was still some configuration thing that's interfering.

    I've been talking to the host (as i know him personally) but its hard to find answers when you don't know what questions to ask. I'll contact him again and see what else we can try.

    Perhapse from here on out the answer lies between me and his configuration.
    Still if there's any more advice you guys can offer, please post.
    Thanks.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width