7 Replies - 8197 Views - Last Post: 08 February 2011 - 11:51 AM Rate Topic: -----

#1 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Connecting to a online MySQL database

Posted 08 February 2011 - 10:25 AM

Hi i got some problems with my connection to a MySQL database so this is my code:
 Dim conn As MySqlConnection
        'connect to DB
        conn = New MySqlConnection()
        conn.ConnectionString = "server=**จจ**จจ.com; user id=****จจจ***; password=***จจจ**จจ**; database=**จจ**จจ**จจ"
        'see if connection failed.
        Try
            conn.Open()
        Catch myerror As MySqlException
            MsgBox("Error:" & myerror.ToString)
        End Try
        'sql query
        Dim myAdapter As New MySqlDataAdapter

        Dim sqlquery = "SELECT * FROM login WHERE username='" + txtuser.Text + "' AND password= '" + txtpass.Text + "'"
        Dim myCommand As New MySqlCommand()
        myCommand.Connection = conn
        myCommand.CommandText = sqlquery
        'start query
        myAdapter.SelectCommand = myCommand
        Dim myData As MySqlDataReader
        myData = myCommand.ExecuteReader()
        'see if user exists
        If myData.HasRows = 0 Then
            MsgBox("Invalid username and/or password!")
        Else
            MsgBox("Login Accepted!")
            Form2.Show()
            Me.Hide()
        End If

i got this error:MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.Exception: Exception of type 'System.Exception' was thrown.
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at Go_For_Code_Share.Form1.Button1_Click_1(Object sender, EventArgs e) in C:\Users\Arno Cornette\AppData\Local\Temporary Projects\Go For Code Share\Form1.vb:line 15

Hope you can help ^^

Thanks


Arno Cornette

Is This A Good Question/Topic? 0
  • +

Replies To: Connecting to a online MySQL database

#2 TADS  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 161
  • Joined: 09-August 08

Re: Connecting to a online MySQL database

Posted 08 February 2011 - 10:32 AM

If this is a mysql on a webhost, you need to set the host to accept % for accepting ALL incoming ip's most mysql databases dont accept incoming connections other then localhost

try that 1st
Was This Post Helpful? 1
  • +
  • -

#3 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Connecting to a online MySQL database

Posted 08 February 2011 - 11:10 AM

oke thanks for that but where do i need to put the % in the connection string ???


Thanks
Arno(Cornetto456)
Was This Post Helpful? 0
  • +
  • -

#4 TADS  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 161
  • Joined: 09-August 08

Re: Connecting to a online MySQL database

Posted 08 February 2011 - 11:13 AM

you dont... you have to do that server side... IF you are using cpanel go into Remote mysql and you place add % host
Was This Post Helpful? 1
  • +
  • -

#5 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Connecting to a online MySQL database

Posted 08 February 2011 - 11:21 AM

im not a paying member and im also not willing to pay :S

but isn't there other website that are hosting free mysql database

my host is for websites


or dosn't exist somthing like a host that only host mysql datbase ???

thanks
Was This Post Helpful? 0
  • +
  • -

#6 TADS  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 161
  • Joined: 09-August 08

Re: Connecting to a online MySQL database

Posted 08 February 2011 - 11:31 AM

for your web hosting are you using cpanel?

if so go to cpanel and click Remote mysql
Posted Image

image from cpanel

if you are not using cpanel you will have to google how to set incoming connect on mysql database

hope this helps

Kev

This post has been edited by TADS: 08 February 2011 - 11:31 AM

Was This Post Helpful? 1
  • +
  • -

#7 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Connecting to a online MySQL database

Posted 08 February 2011 - 11:32 AM

i found a webhost that use cpanel so thanks i gona try it ^^

Thanks
Arno(cornetto456)
Was This Post Helpful? 0
  • +
  • -

#8 cornetto456  Icon User is offline

  • D.I.C Regular

Reputation: 21
  • View blog
  • Posts: 438
  • Joined: 03-January 11

Re: Connecting to a online MySQL database

Posted 08 February 2011 - 11:51 AM

View PostTADS, on 08 February 2011 - 11:31 AM, said:

for your web hosting are you using cpanel?

if so go to cpanel and click Remote mysql
Posted Image

image from cpanel

if you are not using cpanel you will have to google how to set incoming connect on mysql database

hope this helps

Kev

What if i don't have that function ???

Thanks

Arno(Cornetto456)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1