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()

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.