Hi guys, i have a login page where i created a session trainer after login. the session is the mail address of the trainer.

now from another apsx page, i would like to retrieve the staffid of the user logged in using the session as criteria.
I tried to write the below code but its not working. Any ideas please?

  Dim cmd As New SqlCommand
        Dim query1 As String

        query1 = "SELECT staffid FROM tblstaff WHERE email='" & Session("trainer") & "'"

        connect.ConnectionString = Constr

        cmd = New SqlCommand(query1, connect)

        Dim rdr As SqlDataReader = cmd.ExecuteReader
        Dim bFound As Boolean = False
        If rdr.Read() Then
            Dim staffid As String = rdr("staffid")
            lblStaffID.Text = staffid

        End If

Re: retrieve data from table with session as criteria 80 80

Do you get any error message? Enclose in a try/catch. Variable bFound is what for?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.