Can someone tell me what's wrong:
Imports MySql.Data.MySqlClient
Public Class Login
Dim server As String = "Server=localhost;Database=escola_musica;Uid=root;Pwd=;"
Dim con As New MySqlConnection
Dim da As New MySqlDataAdapter
Dim sql As String
Dim cmd As New MySqlCommand(sql, con)
Dim dr As MySqlDataReader
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Ligação à BD
con.ConnectionString = server
Try
If con.State = ConnectionState.Closed Then
con.Open()
Else
con.Close()
MsgBox("Ligação falhada!!")
End If
Catch erro As Exception
MsgBox(erro.ToString)
End Try
'Log in
sql = "SELECT (username, pass) FROM admin WHERE username = " & user_box.Text & ", pass = " & pass_box.Text & ""
With cmd
.CommandText = sql
.CommandType = CommandType.Text
.Connection = con
.ExecuteReader()
End With
con.Open()
dr = cmd.ExecuteReader
If dr.Read Then
If (dr("username") <> user_box.Text) Or (dr("pass") <> pass_box.Text) Then
MsgBox("Utilizador ou pass invalida")
Exit Sub
Else
MsgBox("correcto!")
Principal.Show()
con.Close()
Me.Close()
Exit Sub
End If
End If
If Trim(user_box.Text) <> "" And Trim(pass_box.Text) <> "" Then
Principal.Show()
Me.Close()
Else
MsgBox("erro! -.-' ")
End If
End Sub
Private Sub reg_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles reg_button.Click
Admin_Reg.Show()
Me.Close()
End Sub
End Class
Thank You