Need help accessing mysql in vbscript

Discussion in 'MySQL' started by alexpr07, Jun 7, 2009.

  1. #1
    Hi,
    I really need some help accessing mysql in vbscript (I'm trying to automate tasks by adding script to scheduled tasks).

    I've searched the Internet for days but could not find the solution.
    My connection string is as follows:

    Set objConnect = CreateObject("ADODB.Connection")
    ConnectionString="DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; PORT=3306; DATABASE=database_name; OPTION=3"
    objConnect.Open ConnectionString, "username", "password"

    When I execute the script I get "provider is not specified" error. I tried various combinations of the connection string (for example using odbc 5.1 driver) but still have the same error. I tried to set Provide=mysqlprov but then I get "provider is not found" error.

    I downloaded mysql drivers and added to ODBC Data Sources on my server with the name "mydatabase" (when I test it there, it works).
    So I change the connection string to "DSN=mydatabase;" but still get "provider is not specified" error.

    Please help, I don't know what else to do.
    By the way, the following ASP script works (the only difference is the word Server before CreateObject):

    Set objConnect = Server.CreateObject("ADODB.Connection")
    ConnectionString="DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; PORT=3306; DATABASE=database_name; OPTION=3"
    objConnect.Open ConnectionString, "username", "password"
     
    alexpr07, Jun 7, 2009 IP
  2. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #2
    You provided a snippet of code that works, what is the question? The CreateObject method is a member of the Server object, so you must use Server.CreateObject to create the new instance.
     
    Social.Network, Jun 7, 2009 IP
  3. alexpr07

    alexpr07 Active Member

    Messages:
    284
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #3
    Nope, it did not work on my server, that's the problem. The vbscript was giving "provider not specified" or "provider not found" errors.

    Changing DSN=mydatabase did not work either. When I would put "Provider=MSDASQL.1" it would give me "provider not found" error.
     
    alexpr07, Jun 7, 2009 IP
  4. Social.Network

    Social.Network Member

    Messages:
    517
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    35
    #4
    If I understand this correctly, the snippet works on one server and not another. If so, did you install the MySQL provider (driver) on the server where it is not working?
     
    Social.Network, Jun 7, 2009 IP