my code is as follows ::
Public Function exists(ByVal username As String, ByVal pwd As String)
Dim con1 As New SqlConnection(" server=(local);uid=sa;pwd=;database=usersdb;")
Dim myreader1 As SqlDataReader
Dim eid
Dim cnt, count As Integer
Dim ex As Boolean
Try
con1.Open()
Dim sqlcommand1 As SqlCommand
sqlcommand1 = New SqlCommand("select eid,cnt as count(*) from userdetails where usrname = '" & username & "' and pwd=' " & pwd & "' ", con1)
myreader1 = sqlcommand1.ExecuteReader()
Do While (myreader1.Read())
eid = myreader1("eid").ToString()
ex = True
Loop
Finally
If Not (myreader1 Is Nothing) Then
ex = False
myreader1.Close()
con1.Close()
End If
End Try
If ex Then
Label2.Text = "user Exists"
Else
Label2.Text = "User does not exists"
End If
End Function
|