Tracking session state within business object class

O

oj

Could someone explain to me why the following code snippet throws an
"Object Reference not set to an instance of an object error":


public void SetActiveStaffMember(int staffMemberId)

{

DAL.StaffMemberDataSet smDS = new DAL.StaffMemberDataSet();

if(GetStaffMemberById(staffMemberId) == 0)

smDS = staffMemberDS;

System.Web.HttpContext.Current.Session["smDS"] = smDS;

}




and why the following code does not throw the error:



public void SetActiveStaffMember(int staffMemberId)

{

DAL.StaffMemberDataSet smDS = new DAL.StaffMemberDataSet();

if(GetStaffMemberById(staffMemberId) == 0)

smDS = staffMemberDS;

}




I would like to track Session state for the dataset member of my
business object class, but it seems that this is causing the issue.
Any info. is appreciated.
 
G

Guest

Turn on Option Strict
Set a quick watch on your staffMemberDS variable. See what value it has at
runtime.
 

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,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top