简体   繁体   中英

VB.net and MYSQL5 connection

I'm having a great deal of trouble finding code examples to connect a VB.net client application I am writing to a MYSQL5 database. I am trying to access a database I created through WAMP and phpMyAdmin.

where on the internet is a simple example of a programmatic implementation of an object I can use to connect these two seemingly un-connectable entities?

Just to make it a bit clearer:

I have a DB made through phpMyAdmin called: test within the db is a table: sys_users within the table are: user_ID (pk), user_name, user_password

simply looking to connect VB.net to test and query the table sys_users, returning a boolean if they exist. From there, I can figure out the rest of my solution for my program dealing with other tables and data.

thanks for any help in this.

Imports MySql.Data.MySqlClient Imports System.Data.SqlClient

Public Class login Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim strConStr As String = "Data Source=localhost;uid=********;pwd=********;database=********" Dim conn As MySqlConnection conn = New MySqlConnection(strConStr) MsgBox(conn.ConnectionString.ToString)

    Try
        conn.Open()
        MessageBox.Show("Connection Opened Successfully")
        conn.Close()
    Catch myerror As MySqlException
        MessageBox.Show("Error Connecting to Database: " & myerror.Message)
    Finally
        conn.Dispose()
    End Try
End Sub

End Class

Yes, this was a problem for someone else, but the solution seems to work so far. As for the Password validation etc, I will most definitely make use of it. All I needed guys, thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM