0

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
        connect.Open()

        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
        rdr.Close()

        connect.Close()

Edited by happygeek: moved

2
Contributors
1
Reply
13
Views
3 Months
Discussion Span
Last Post by xrj
0

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

This question has already been answered. 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.