Results 1 to 2 of 2
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MySQL Connection (Word2000/vba)

    I'd appreciate any Word/VBA/MySql (or Excel/VBA/MySql for that matter) experts casting a withering glance over the attached code.
    Three years ago I was able to connect to a client's MySQL database, but today, on cloning that VBA code I can't get a connection to my own (new and functioning) database.
    I say "new and functioning" because it's my DLGuard store, and it runs well.
    I should add that I have "allow remote access" turned on at the host site.

    I copy/pasted the server, port, database name, user name and password directly from the Control Panel on my hosting page.
    My Tools, References are as shown in the screen snapshot.
    (This is another of those hurdles where, I hope, you'll hear me slapping my forehead Real Soon Now (tm) )

    <pre>Public Sub NewGenlet()
    Dim strServer As String
    Dim strPort As String
    Dim strDatabase As String
    Dim strUserId As String
    Dim strPassword As String
    strServer = "mysql.netfirms.ca"
    strPort = "3306"
    strDatabase = "d605*****" ' not really
    strUserId = "u705*****" ' not really
    strPassword = "9*****" ' not really
    '''
    Dim AConn As New ADODB.Connection
    Dim strConn As String
    strConn = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER="
    strConn = strConn & strServer
    strConn = strConn & "; Po<font color=red>r</font color=red>t=" ' (later: ooops, but still doesn't connect)
    strConn = strConn & strPort
    strConn = strConn & "; DATABASE="
    strConn = strConn & strDatabase
    strConn = strConn & "; Uid="
    strConn = strConn & strUserId
    strConn = strConn & "; Pwd="
    strConn = strConn & strPassword
    strConn = strConn & ";"
    Debug.Print strConn
    AConn.ConnectionString = strConn
    On Error GoTo Failed
    AConn.Open ' produces the following error
    ' DRIVER={MySQL ODBC 3.51 Driver}; SERVER=mysql.netfirms.ca; Pont=3306; DATABASE=d60521; Uid=u703; Pwd=93;
    ' Unidentified error when trying to connect to the database: -2147467259
    AConn.Close
    Exit Sub
    Failed:
    Select Case Err.Number
    Case Else
    Debug.Print "Unidentified error when trying to connect to the database: " & Err.Number
    MsgBox "Unidentified error when trying to connect to the database: " & Err.Number
    End Select
    End Sub</pre>

    Attached Images Attached Images
    • File Type: jpg 1.JPG (35.7 KB, 0 views)

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MySQL Connection (Word2000/vba)

    Edited by StuartR to break very long preformatted line which caused the browser window to scroll horizontally

    <pre>> We have taken a look at your remote mysql connection, and after a refresh on your account
    > we are happy to inform you that we are able to connect to your account remotely.
    > Please use the following when connecting for the SERVER/Host = mysql.netfirms.com</pre>


    The above from my hosts.
    I still have no idea how to detect the need for a "refresh", or how to initiate it at my end.

    I post this self-reply to assure readers that the sample code (<post#=745,038>post 745,038</post#>) is correct, and that it does now work as it should.

Posting Permissions

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