У меня есть форма Windows, которая принимает имя пользователя и пароль.Он проверяет его с помощью созданной мной базы данных, которая содержит правильные имена пользователей и пароли.Поэтому я реализовал код для проверки правильности введенных данных.
Вот мой код:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
myconnection = New SqlConnection("server=PARTH-PC\SQLEXPRESS;uid=sa;pwd=demo;database=fc")
'you need to provide password for sql server
myconnection.Open()
TextBox1.Text = userid
TextBox2.Text = password
mycommand = New SqlCommand("select * from student where user id='" & TextBox1.Text & "' and password='" & TextBox2.Text & "')", myconnection)
Catch ex As Exception
Finally
End Try
Try
If EOF(1) Then
MessageBox.Show("Access Denied...Please enter correct password!")
TextBox1.Text = ""
TextBox2.Text = ""
'txtUserName.SetFocus()
Else
Txt = "" & " " & UCase$(TextBox1.Text) & ""
MsgBox("Welcome!!!" & Txt)
Form2.Show()
End If
Catch ex As Exception
End Try
myconnection.Close()
End Sub
End Class
Я столкнулся с проблемой в этом коде ... он работает неправильнокто-нибудь может мне помочь