troubleshooting Question

Store single record two values to ASP. NET Session using a Function running a ExecuteReader by executing a Sql Stored Procedure

Avatar of Cobra967
Cobra967Flag for United States of America asked on
ASP.NETMicrosoft SQL Server
2 Comments1 Solution145 ViewsLast Modified:
Hello, I have a Sql Server stored procedure that return a single record with two columns in it (Role_Id and Program_Id). I currently have a function in Asp.Net VB.Net that will execute the Stored procedure and return the Role_Id and then store the result in a Session. However, from the same Function I would like to retrieve the Role_Id and the Program_Id and store the Program_Id in a different session. How do I accomplish this (I already managed for the stored procedure to return both values - Both Integers)?

       Session("ProgramId") = GetRole(?)

        Session("UserRole") = GetRole()

Private Function GetRole() As Int32
        Try

            Dim con As SqlConnection = GetSqlConnection()
            Dim cmd As New SqlCommand() With {.CommandText = "GetRole", .CommandType = CommandType.StoredProcedure, .Connection = con}
            cmd.Parameters.Add(New SqlClient.SqlParameter("@UserName", Session.Item("EmployeeId")))
            con.Open()
            Dim Role As Int32 = DirectCast(cmd.ExecuteScalar(), Int32)
            Return Role
            con.Close()

        Catch generatedExceptionName As Exception
            'HttpContext.Current.Response.Redirect("~/ErrorRedirect.aspx", False)

        End Try

    End Function
ASKER CERTIFIED SOLUTION
Paul MacDonald
Director, Information Systems

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros