Results 1 to 4 of 4

Thread: [RESOLVED] How do I connect a form to mysql database?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Location
    UK - OK
    Posts
    72

    Resolved [RESOLVED] How do I connect a form to mysql database?

    Howdy,

    I've followed a guide as to how I connect a form to mysql as per:

    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
    TestConnection()
    End Sub

    Public Sub TestConnection()
    Try
    Dim connStr As String = "Database=ClockInOut;" & _
    "Data Source=192.168.0.87;" & _
    "User Id=Username;Password=Password"
    Dim connection As New MySqlConnection(connStr)
    connection.Open()
    connection.Close()
    MsgBox("Connection is okay.")
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End Sub

    And when I launch the form I get the error "unable to connect to the specified hosts"

    Does anyone have any ideas?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: How do I connect a form to mysql database?

    the IP address doesn't exist... use either the machine name, or "localhost"...

    or it's possible your user isn't set up for remote connections.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Location
    UK - OK
    Posts
    72

    Re: How do I connect a form to mysql database?

    Ok thanks, I have put the fqdn of the machine in but that still doesnt work. I also changed the connection username to root to test and that doesnt work either. Its not localhost as the mysql db is on apache server and I am connecting from a windows box?


  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Location
    UK - OK
    Posts
    72

    Re: How do I connect a form to mysql database?

    Fixed - had to add the IP address of the remote machine to the allowed list on mysql. It now connects

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