Try
Dim SQL_Connection As MySqlConnection = New MySqlConnection("Database=Data1;Server=localhost;User Id=root;Password=12345;Pooling=false")
Dim query As String = "SELECT Username FROM user WHERE Username = '" & tb_Username.Text & "'"
Dim sqlCmd As New MySqlCommand
Dim dr As MySqlDataReader
SQL_Connection.Open()
With sqlCmd
.Connection = SQL_Connection
.CommandText = query
End With
dr = sqlCmd.ExecuteReader()
Do While dr.Read
Label1.Text = "ชื่อ: " & tb_Username.Text
Label2.Text = "ตำแหน่ง: " & dr("Status") 'อยากให้อันนี้มันโชว์ แต่มันไม่โชว์
Loop
SQL_Connection.Dispose()
SQL_Connection.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
ใน Mysql มี
CREATE TABLE `user` (
`Username` varchar(10) NOT NULL,
`Password` varchar(10) NOT NULL,
`Status` enum('Owner','Admin') NOT NULL default 'Admin'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- dump ตาราง `user`
--
INSERT INTO `user` VALUES ('Owner', '123456', 'Owner');
INSERT INTO `user` VALUES ('Admin', '123456', 'Admin');