watherton
November 13th, 2003, 11:58 AM
I was wondering if anyone could help me with a problem with the some code.
I am trying to create a dataset based on an application varibale from the Global.asa file.
the following code is being called:
string GetProfile(string name)
{
DataSet ds = (DataSet) Application["Profile"];
DataRow[] rows = ds.Tables[0].Select("User_ProfileID Where User_Username='" + name + "'");
if (rows.Length >0)
return rows[0]["User_Roles"].ToString();
else
return "";
}
and the application varible code is:
protected void Application_Start(Object sender, EventArgs e)
{
SqlConnection objconn = new SqlConnection(ConfigurationSettings.AppSettings["V2"]);
string objcmd2 = "Select User_ProfileID, User_UserName from UserList";
SqlDataAdapter Profile = new SqlDataAdapter(objcmd2,objconn);
DataSet ds2 = new DataSet();
Profile.Fill(ds2);
Application["ProfileID"] = ds2;
}
when i try and run the page i get the following error message
Object reference not set to an instance of an object.
point at this line:
DataRow[] rows = ds.Tables[0].Select("User_ProfileID Where User_Username='" + name + "'");
please help if you can.
cheers
I am trying to create a dataset based on an application varibale from the Global.asa file.
the following code is being called:
string GetProfile(string name)
{
DataSet ds = (DataSet) Application["Profile"];
DataRow[] rows = ds.Tables[0].Select("User_ProfileID Where User_Username='" + name + "'");
if (rows.Length >0)
return rows[0]["User_Roles"].ToString();
else
return "";
}
and the application varible code is:
protected void Application_Start(Object sender, EventArgs e)
{
SqlConnection objconn = new SqlConnection(ConfigurationSettings.AppSettings["V2"]);
string objcmd2 = "Select User_ProfileID, User_UserName from UserList";
SqlDataAdapter Profile = new SqlDataAdapter(objcmd2,objconn);
DataSet ds2 = new DataSet();
Profile.Fill(ds2);
Application["ProfileID"] = ds2;
}
when i try and run the page i get the following error message
Object reference not set to an instance of an object.
point at this line:
DataRow[] rows = ds.Tables[0].Select("User_ProfileID Where User_Username='" + name + "'");
please help if you can.
cheers