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

Please put CODE tags around code to preserve formatting. After pasting the code, select all code and click on the CODE tool at the top of the edit winidow.

We can't help without a few details such as what happens when you try to run this code. What errors do you get and on what line?

So whats the problem you are having? any error code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.