Session Variables

J

J. Ptak

Hey Tibby.

The proper way to create a session variable is:

Session["VarName"] = value;

Or you can use the Add method as:

Session.Add("VarName", value);

Either way will work.

Next to remove an item from the session state:

Session.Remove("VarName");

To clear all items from the session state use:

Session.Clear();

HTH.

Jeff Ptak
 
T

Tibby

Just to make sure I'm playing ball here, so, instead of using Dim myVar as
string, then later using myVar="Kiss Me", I would use Session["myVar"]="Kiss
Me", then to reference it, I would use something like
MsgBox(Session["myVar"])
Just to make sure I'm on the same page.

Thanks
Tibby

J. Ptak said:
Hey Tibby.

The proper way to create a session variable is:

Session["VarName"] = value;

Or you can use the Add method as:

Session.Add("VarName", value);

Either way will work.

Next to remove an item from the session state:

Session.Remove("VarName");

To clear all items from the session state use:

Session.Clear();

HTH.

Jeff Ptak

-----Original Message-----
What is the proper way to creating Session Variables and destroying them. I
think this is what my major problem is. And, can that be done also for
ADO.NET objects?

Thanks
Tibby


.
 
T

Tibby

I apoligize, I'm using VB.Net.

Kevin Spencer said:
Forget about "MsgBox." That function is not for ASP.Net pages. It is only
used for Windows Forms. Other than that, you are basically corrrect.
However, it is hard to tell whether you're using VB.Net or C# from your
example, as the MsgBox function is a VB.Net function, but your syntax for
the Session variable is C#. Here are 2 examples, using VB.Net and C#:

VB.Net: Session("myVar") = "Kiss Me"
C#: Session["myVar"] = "Kiss Me";

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

Tibby said:
Just to make sure I'm playing ball here, so, instead of using Dim myVar as
string, then later using myVar="Kiss Me", I would use Session["myVar"]="Kiss
Me", then to reference it, I would use something like
MsgBox(Session["myVar"])
Just to make sure I'm on the same page.

Thanks
Tibby

J. Ptak said:
Hey Tibby.

The proper way to create a session variable is:

Session["VarName"] = value;

Or you can use the Add method as:

Session.Add("VarName", value);

Either way will work.

Next to remove an item from the session state:

Session.Remove("VarName");

To clear all items from the session state use:

Session.Clear();

HTH.

Jeff Ptak


-----Original Message-----
What is the proper way to creating Session Variables and
destroying them. I
think this is what my major problem is. And, can that be
done also for
ADO.NET objects?

Thanks
Tibby


.
 
K

Kevin Spencer

No apology neccessary! That's what we're here for. :)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

Tibby said:
I apoligize, I'm using VB.Net.

Kevin Spencer said:
Forget about "MsgBox." That function is not for ASP.Net pages. It is only
used for Windows Forms. Other than that, you are basically corrrect.
However, it is hard to tell whether you're using VB.Net or C# from your
example, as the MsgBox function is a VB.Net function, but your syntax for
the Session variable is C#. Here are 2 examples, using VB.Net and C#:

VB.Net: Session("myVar") = "Kiss Me"
C#: Session["myVar"] = "Kiss Me";

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.

Tibby said:
Just to make sure I'm playing ball here, so, instead of using Dim
myVar
as
string, then later using myVar="Kiss Me", I would use Session["myVar"]="Kiss
Me", then to reference it, I would use something like
MsgBox(Session["myVar"])
Just to make sure I'm on the same page.

Thanks
Tibby

Hey Tibby.

The proper way to create a session variable is:

Session["VarName"] = value;

Or you can use the Add method as:

Session.Add("VarName", value);

Either way will work.

Next to remove an item from the session state:

Session.Remove("VarName");

To clear all items from the session state use:

Session.Clear();

HTH.

Jeff Ptak


-----Original Message-----
What is the proper way to creating Session Variables and
destroying them. I
think this is what my major problem is. And, can that be
done also for
ADO.NET objects?

Thanks
Tibby


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top