When a user logs in to my system, the string for the connection to the database is pulled out of a table and stored in a Session Variable. For my function to have the correct connection string in saving to the database, I want to be able to use the string stored in the Session Variable.
In a normal Subroutine, I can use strConnection = Session("ConnectionString")
But wth a function, I don't have this option. I could feed the connection string in as a parameter when calling the function, but don't want to do that.
How can I get the session variable when calling a function.
Your class files will need a reference to the System.Web assembly.
You can access curent Session via:
I may be wrong but are you trying to use session variable in another class or code file besides the page? Try using the the line below...
ConnectionString = System.Web.HttpContext.Current.Session("ConnectionString").ToString()
Apologies if I am wrong....
[Please mark the post as answer that helps you.]
Farhan Uddin Khan
Microsoft Certified Solution Developer
Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as
Answer" if a marked post does not actually answer your question.
Thanks for the reply.
I am using VS 2008, VB, server side function