*Two Namespaces are must be required for SqlServer Connectivity:-
1. Import System.Data
2. Import System.Data.SqlClient
Private
Sub btnLogin_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs)
Handles btnLogin.Click
Dim
StrCon As String = "Data Source=PRADEEP-HP;Initial Catalog=Sample;Integrated Security=True"
Dim
SqlCon As SqlConnection
= New SqlConnection(StrCon)
Dim
SqlQuery As String = "Select EmpId,EmpName,Password from EMPTable where EmpName='" + txtName.Text + "' and Password='" + txtPwd.Text + "'"
Dim
SqlCom As SqlCommand = New
SqlCommand(SqlQuery, SqlCon)
SqlCon.Open()
Dim
Dr As SqlDataReader
Dr =
SqlCom.ExecuteReader()
If
(Dr.Read()) Then
If
(txtName.Text = Dr("EmpName").ToString()
And txtPwd.Text = Dr("Password").ToString()) Then
Dim
obj2 As New Form2
obj2.Show()
Me.Hide()
End
If
End
If
End
Sub
0 comments
Post a Comment