-
Jan 16th, 2013, 06:45 AM
#1
Thread Starter
New Member
Connect to mysql
Hi everyone, i would really need som help please, i have programed in Visul basic 2010 a login system, i have made everything in phpmyadmin etc and whene i try to connect to the server i just get that Unable to connect to any of the specified MySQL hosts. Can anyone help me pleas and locate the problem?
here is the whole code
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class LoginForm1
Dim mysqlconnection As MySqlConnection
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
mysqlconnection = New MySqlConnection
mysqlconnection.ConnectionString = "server=remote-mysql3.servage.net;Port=3306; user id=fifaligan; password=xxxxx; database=fifaligan
mysqlconnection.Open()
Dim myadapter As New MySqlDataAdapter
Dim sqlquary = "SELECT * From Users WHERE Username='" & UsernameTextBox.Text & "'AND Password='" & PasswordTextBox.Text & "';"
Dim command As New MySqlCommand
command.Connection = mysqlconnection
command.CommandText = sqlquary
myadapter.SelectCommand = command
Dim mydata As MySqlDataReader
mydata = command.ExecuteReader
If mydata.HasRows = 0 Then
MsgBox("Fel inloggnings information")
Else
Form10.Show()
Me.Close()
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
End Class
-
Jan 16th, 2013, 10:04 AM
#2
Re: Connect to mysql
The connection string doesn't quite look right...
http://www.connectionstrings.com/mysql
should look like this:
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
-tg
-
Jan 17th, 2013, 01:53 AM
#3
Thread Starter
New Member
Re: Connect to mysql
tried it but it doesnt work :/
-
Jan 17th, 2013, 03:26 AM
#4
Re: Connect to mysql
Just saying that it doesn't work doesn't help us all that much. What actually happens when you run the code? If an exception is thrown, what's the error message and where does it occur? Have you conformed that your connection string is of an appropriate format as provided at www.connectionstrings.com?
You should also be using parameters to insert values into SQL code rather than string concatenation. To learn why and how, follow the Blog link in my signature and check out my post on Parameters In ADO.NET.
Finally, please wrap your code snippets in [code][/code] or [highlight=vb.net][/highlight] tags for readability.
-
Jan 17th, 2013, 03:50 AM
#5
Thread Starter
New Member
-
Jan 17th, 2013, 04:12 AM
#6
Re: Connect to mysql
That suggests that the server or port number are incorrect. I just had a look at servage.net and they say that you have to specifically choose that the database be remotely accessible when you create it. Did you do that? The server name you're using suggests that it is but I thought that I'd check. The code looks basically correct so there's just a problem with your connection string details, so you need to reconfirm those.
This is a database issue more than a VB.NET issue so I'm going to ask the mods to move this thread to the Database forum. You may get more people with MySQL-specific experience there.
-
Jan 17th, 2013, 04:31 AM
#7
Re: Connect to mysql
Moved to the Database Development forum.
-
Jan 17th, 2013, 04:45 AM
#8
Thread Starter
New Member
Re: Connect to mysql
Ok, i have been in conntact with the ppl that have the database, and its open for remotley access:/ better if i find someone that wana do it for me, and pay for the help
-
Jan 17th, 2013, 05:36 AM
#9
Re: Connect to mysql
Originally Posted by zanris
Ok, i have been in conntact with the ppl that have the database, and its open for remotley access:/ better if i find someone that wana do it for me, and pay for the help
Not sure this will help but you might need to add the ip address of the computer you are accessing the database from to the "Remote" section of the server control panel.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Jan 17th, 2013, 05:42 AM
#10
Thread Starter
New Member
Re: Connect to mysql
but i want everyone to access the login from "all computers in the world" just login to my exe program to the database with the login information.
So then i shouldnt need to at my computer to it? :O
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|