Results 1 to 10 of 10

Thread: Connect to mysql

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    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

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,538

    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
    * 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
    New Member
    Join Date
    Jan 2013
    Posts
    10

    Re: Connect to mysql

    tried it but it doesnt work :/

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    Re: Connect to mysql

    Hi! thx for reply!

    Page 1 is the code:
    Name:  page1..png
Views: 166
Size:  45.1 KB

    Page 2 is login: and whene i log in this happens (on page 3)
    Name:  page2.png
Views: 155
Size:  41.5 KB

    Page 3 error msg:
    Name:  page3..png
Views: 172
Size:  52.7 KB

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    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.

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Connect to mysql

    Moved to the Database Development forum.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    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

  9. #9
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Connect to mysql

    Quote Originally Posted by zanris View Post
    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

  10. #10

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    10

    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
  •  



Click Here to Expand Forum to Full Width