Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this query in sp
SQL
  SELECT [Login_Id]
    ,[User_Name]
    ,[Password]
    ,[Role_Id]
FROM [dbo].[Login]
Where [User_Name] =@User_Name
    and [Password] =@Password

now on i want to save User Id and Role Id into session variable on aspx page how can i do this?
Posted
Comments
Dinesh.V.Kumar 8-Feb-14 9:57am    
I am not exactly clear on what you want...but assuming that, on executing the SP you get the result in a data table. After this use the below code
Session["UserID"] = dataTable.Rows[0]["Login_ID"];
Session["RoleID"] = dataTable.Rows[0]["Role_ID"];

Regards
Muhamad Faizan Khan 8-Feb-14 10:48am    
Thanks alot

If you don't know how to do something basic, then start with google. In this case it leads very quickly here: http://msdn.microsoft.com/en-us/library/ms178581.aspx[^] which explains the whole process.
 
Share this answer
 
Execute this query with the help of ADO.NET objects.
With the help of these objects bind results to any variable or DataTable, then store in Session or directly store those values in Session.

You can easily get examples on how to deal with ADO.NET objects, execute queries and fetch the values.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900