#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Canada
    Posts
    19
    Rep Power
    0

    vb6 problem (newbie question)


    So I finally figured out how to connect to my mysql database and insert the appropriate fields. I used vb dev. and opened up a standard.exe file and placed the following code which was assigned to a button. Every time that I click the button, it inserts the values into my database. (it works)

    ----------------------

    Private Sub Command1_Click()

    'set up the connection to my table

    Dim conn As New ADODB.Connection
    conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=phone_number;UID=root;PWD=legend;"
    conn.CursorLocation = adUseClient
    conn.Open


    'inserts the values in the database
    conn.Execute "INSERT INTO phone_1(phone_number, name_id) values('value_1','value_2')"


    End Sub

    ---------------

    Now for some strange reason this code only works in the original vb file that I made. When I try make another one, it gives me a compile error. It makes me wonder how I got it to work in the first place. This code is useless unless I can put it in other vb scripts.. Also, it freaks me out..because I can't even reproduce the same document and get it to work without a compile error.

    I follow the same original steps... Create new vb script.exe, insert command button, double click on the command button, paste the code... and voila.. IT DOES NOT WORK?!?!

    Why does my original work and the reproductions give me compile errors?

    please help, thanks in advance...
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    Right off hand I would say to make sure that you have a reference to the ado library set up in your project.

    Also, please post visual basic related questions in the visual basic forum. This forum is for C languages.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Canada
    Posts
    19
    Rep Power
    0

    Talking sorry


    I didn't realize that it was in the wrong area.

    on the upside, you were right about the refrence...

    thank you

IMN logo majestic logo threadwatch logo seochat tools logo