Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.SqlClient
- Class MainWindow
- Private Sub BtnLogin_Click(sender As Object, e As RoutedEventArgs) Handles btnLogin.Click
- End Sub
- Sub CheckLogin()
- Dim RetVal As Integer
- Dim conn = New SqlConnection("Data Source=(localdb)MSSQLLocalDB;Initial Catalog=dbProject;Integrated Security=True")
- Using cmd = New SqlCommand("select count(*) from tblLogin where username = @Username and password= @Password;", conn)
- cmd.Parameters.Add("@Username", System.Data.SqlDbType.VarChar).Value = txtUsername.Text.Trim
- cmd.Parameters.Add("@Password", System.Data.SqlDbType.VarChar).Value = txtPassword.Text.Trim
- conn.Open()
- If conn.State = ConnectionState.Open Then
- RetVal = CInt(cmd.ExecuteScalar)
- If RetVal = 1 Then
- Else
- txtUsername.Clear()
- txtPassword.Clear()
- txtUsername.Focus()
- End If
- Else
- MessageBox.Show("The connection is not open, contact an administrator!")
- End
- End If
- End Using
- End Sub
- End Class
Add Comment
Please, Sign In to add comment