Results 1 to 10 of 10

Thread: How to write form data into external mysql db?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow How to write form data into external mysql db?

    HI every body. I have a visual basic 6 form that has one dropdown box and one text box and a button. I want to collect the input values and write it to external mysql database that is in diffrent server.I be happy if an expert show me how to achive this task.Thanks

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to write form data into external mysql db?

    just set up a connection to the MySQL server and use the execute command
    something like this:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim CNN As New Connection
    3.     CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=data.domain.com;PORT=3306;DATABASE=myDatabase; USER=myUsername;PASSWORD=myPassword;OPTION=3;"
    4.     If CNN.State <> 0 Then
    5.         CNN.Execute "INSERT INTO TableName VALUES...."
    6.        
    7.         CNN.Close
    8.     End If
    9.  
    10. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: How to write form data into external mysql db?

    Many thank for u reply. could u tell me how i can grab the form input values from drop down box and text box and place it in sql statement ? Thanks

  4. #4
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to write form data into external mysql db?

    CNN.Execute "INSERT INTO TableName VALUES('" & text1.text & "','" & combo1.text & "')"
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: How to write form data into external mysql db?

    Quote Originally Posted by Static
    CNN.Execute "INSERT INTO TableName VALUES('" & text1.text & "','" & combo1.text & "')"
    Many thanks for u reply.when i input data and press submit button in my I get the follwoing error:

    Code:
    compile error:
    
    User-defined type not defined
    and it pointing to this line :
    Dim CNN As New Connection

    Do i need to have any driver installed in my pc? do i need to drag any connection typee to my form? furthermore i am using free site website such as www.tripod.lycos.nl for testing. do think the server value is :www.tripod.lycos.nl or ftp.tripod.lycos.nl?
    I be happy if u help me here.Thanks
    Last edited by tony007; Apr 11th, 2006 at 09:32 AM.

  6. #6
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to write form data into external mysql db?

    u need to add a reference to the ActiveX Data Object 2.8
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: How to write form data into external mysql db?

    Quote Originally Posted by Static
    u need to add a reference to the ActiveX Data Object 2.8
    Now i get the following error:



    and it is pointing to connection line.
    could u help me fix this problem .Thanks
    Last edited by tony007; Apr 11th, 2006 at 09:40 AM.

  8. #8
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to write form data into external mysql db?

    Project Menu > References
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Talking Re: How to write form data into external mysql db?

    Quote Originally Posted by Static
    Project Menu > References
    Now i get the following error:



    and it is pointing to connection line:

    CNN.Open "DRIVER={MySQL ODBC 3.51 Driver};SERVER=data.domain.com;PORT=3306;DATABASE=myDatabase; USER=myUsername;PASSWORD=myPassword;OPTION=3;"


    could u help me fix this problem .Thanks

  10. #10
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: How to write form data into external mysql db?

    u need to change the data in the connection string to point to your MySQL server...
    data.domain.com.. should be the address of your server...
    myDatabase .. database name
    myUsername. user ID
    myPassword.. and password...

    also.. u may not be using the 3.51 driver...
    have a look here:

    www.connectionstrings.com
    there are other choices (not the .NET ones)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

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