Imports System.Data
Imports MySql.Data.MySqlClient
Imports System.Data.SqlClient
Public Class form1
Dim conn As MySqlConnection
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost; user id=root; password=123456; database=book;"
Dim str As String = "SELECT bookid, bookname FROM book"
Dim cmd As New SqlCommand(str)
End Sub
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Try
conn.Open()
MessageBox.Show("ได้แน่นอน")
conn.Close()
Catch ex As Exception
MessageBox.Show("ไม่ได้อะ" & ex.Message)
End Try
conn.Dispose()
End Sub
End Class