Boa tarde pessoal, gostaria de saber qual o motivo para este codigo estar a dar erro! este codigo está a ser desenvolvido para efetuar o login de utilizadores de uma empresa.
A liguagem e VB
a linha em que me está a dar o erro é:
cmd.CommandText = "select count (*) from Utilizador where Nome = '" & txtUser.Text & "' AND Password = '" & txtPass.Text & "';"
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim connectionString As String = "Password=irpasimpo;Persist Security Info=True;User ID=SA;Initial Catalog=OEI;Data Source=CARLOS-M\SQL"
Dim connection As New SqlConnection(connectionString)
Dim cmd As SqlClient.SqlCommand
connection.Open()
cmd.CommandText = "select count (*) from Utilizador where Nome = '" & txtUser.Text & "' AND Password = '" & txtPass.Text & "';"
cmd.Connection = connection
Dim rowValue As String = cmd.ExecuteScalar
If rowValue = "0" Then
MessageBox.Show("Invalid Login information.", "Ooops!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
txtUser.Focus()
Else
MessageBox.Show("Login success!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
connection.Close()
End Sub
Agradecia toda a ajuda possivel!