Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005

    Talking Unanswered: difficulty inserting data to local mysql server?

    Hi all. I got a simple vb6 form that has a dropdowtn box and a text box and a button . Initially the drop down box is empty and i allow to user to enter value in drop down box and text box and click submit.

    The problem is once i try compile my project i get the following error that shows in pic below

    and it is pointing to connection line:
    CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;PORT=3306;DATABASE=visualbasic6; USER=root;PASSWORD=;OPTION=3;"
    Mysql server is installed locall and has no pass and i already have db with single table on it.

    Could an expert tell me what is wrong that i can not run this project and can not insert data in to mysql db. Furthermore, i am not expert in driver things and connection strings so i hope an expert give me a sample working code and suggestion to get and install needed drivers if it is required.Thanks

    my code:

    Private Sub Command1_Click()
        Dim CNN As New Connection
        CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;PORT=3306;DATABASE=visualbasic6; USER=root;PASSWORD=;OPTION=3;"
        If CNN.State <> 0 Then
            'CNN.Execute "INSERT INTO TableName VALUES...."
            CNN.Execute "INSERT INTO users VALUES('" & Text1.Text & "','" & Combo1.Text & "')"
        End If
    End Sub

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    have a look here for your connection string.

    as to your insert statement, try:

    INSERT INTO yourTable (yourCol1, yourCol2)
    VALUES ('yourValue1', 'yourValue2')
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jun 2004
    Arizona, USA
    It's also probably a good idea to explicitly specify ADO.


    Dim CNN As New ADODB.Connection
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

Posting Permissions

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