Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

create session variable in c#

I try to create session variable in c#.  Here is the code, but it says 'System.Web.UI.Page.Session' is a 'property' but is used like a 'method'       .  Please help.

Session("seq") =  System.Convert.ToString(CMD.ExecuteScalar());
0
ewang1205
Asked:
ewang1205
2 Solutions
 
Raynard7Commented:
Hi,

The problem is that you are using an example that is using old ASP or VBScript principles

for c# the session is an array and as such you should do your assignment in the form

Session["key"] = "value";

http://www.webmonkey.com/webmonkey/03/30/index3a.html?tw=programming
0
 
KelvinYCommented:
Hi ewang1205,

Try
  Session["seq"] =  System.Convert.ToString(CMD.ExecuteScalar());

Regards
  Kelvin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now