The following is my login code for my project..

Function ValidateUser(ByVal uid As String, ByVal pwd As String) As Boolean
       'Dim sName As String
      Dim sUser As String
      Dim sPwd As String
       Dim blnValidUser As Boolean
       blnValidUser = True
       Dim strConn As String = "server=YOGESH\SQLEXPRESS;Trusted_Connection=yes;database=jobbunch.mdf"

      'Dim MySQL As String = "Select [Name], [Login], " & _
        '"[Password] from Employees " & _
        '"Where Login=@uid AND Password=@Pwd"
     Dim MySQL As String = "Select [uid],[pwd] from login where uid=@uid and pwd=@pwd "
      Dim MyConn As New SQLConnection(strConn)
      Dim objDR As SQLDataReader
     Dim Cmd As New SQLCommand(MySQL, MyConn)
      Cmd.Parameters.Add(New SqlParameter("@uid", uid))
     Cmd.Parameters.Add(New SqlParameter("@pwd", pwd))
          objDR = Cmd.ExecuteReader(system.data.CommandBehavior.CloseConnection)
          While objDR.Read()
              sUser = objDR("uid")
             sPwd = objDR("pwd")
                'sName = objDR("Name")
          End While
            'Dim sText As String
            'If sFirst = "" And sLast = "" Then
            '    blnValidUser = "False"
            '    blnValidUser = "True"
            'Session("Name") = sUser
            'End If
     Catch ex As Exception
            blnValidUser = "False"
            'lblError.visible = "true"
            'lblError.text = "Sorry Errors have occurred"
         ValidateUser = blnValidUser
       End Try
   End Function

Basically this code is to fetch the userid and password from the database and perform the validation for the login form.
i performed the debugging activity and after line17 the execution jumps to line 22 i.e an exception is gettin occured..
pls suggest some solution.

9 Years
Discussion Span
Last Post by Aneesh_Argent

but in the project v r using sql server which contains the database for all users..
so v need to connect the .net application to sql server database and then execute the queries..
but if dis can be done in another way..pls suggest how to do it exactly..

i dont know wht kind of exception it is?
just bcoz the control is jumpin to catch statement i came 2 know ki an exception is gettin occured


Rewrite your catch block like this and let me know what message u get on the label

Catch ex As Exception
            blnValidUser = "False"
            lblError.visible = "true"
            'Displays exception message on label
            lblError.text = ex.Message
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.