Dim sqlconn As SqlConnection = New SqlConnection("data source=MCKAYLA\SQLEXPRESS;Initial Catalog=jhen_reg;Integrated Security=True")
Dim sqlda As New SqlDataAdapter
Dim sqlcmd As New SqlCommand
Dim dt As New DataTable
Dim sqlstr As String = "SELECT * FROM reg where Username=@Usernametextbox.text AND Password=@Passwordtextbox.text"
With sqlcmd
.CommandText = sqlstr
.Connection = sqlconn
.Parameters.AddWithValue("@Username", UsernameTextBox.Text)
.Parameters.AddWithValue("@Password", PasswordTextBox.Text)
End With
sqlda.SelectCommand = sqlcmd
sqlda.Fill(dt)
If UsernameTextBox.Text = "" Or PasswordTextBox.Text = "" Then
MsgBox("Please Check Username, Password and Log in level," & UsernameTextBox.Text, MsgBoxStyle.Exclamation, "jhen_reg Alert")
UsernameTextBox.Text = ""
UsernameTextBox.Text = ""
UsernameTextBox.Focus()
ElseIf dt.Rows.Count > 0 Then
MsgBox("Log In Success!, " & UsernameTextBox.Text, MsgBoxStyle.Information, "jhen_reg Log In")
Form1.Show()
Me.Close()
Else
MsgBox("Please Check Username,Password and Log in level," & UsernameTextBox.Text, MsgBoxStyle.Exclamation, "jhen_reg Alert")
UsernameTextBox.Text = ""
UsernameTextBox.Text = ""
UsernameTextBox.Focus()
End If
khia02 0 Newbie Poster
khia02 0 Newbie Poster
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.