Session error

  • Thread starter Thread starter Reena
  • Start date Start date
R

Reena

Hi,

I am working on .NET 2003, C#. I have created a class file and getting...

The name 'Session' does not exist in the class or namespace
'RADWebV5.RADAsp.Class.Connection'

Connection.cs code....

using System;
using System.Data.OracleClient;
using System.Web.SessionState;

namespace RADWebV5.RADAsp.Class
{
/// <summary>
/// Summary description for Connection.
/// </summary>
public class Connection
{
public Connection()
{
//
// TODO: Add constructor logic here
//
}

public static string LogOn(string UserID, string Password)
{
OracleConnection objConnection = null;
OracleDataReader objReader = null;

try
{
Session["UserID"] = UserID;
Session["Password"] = Password;
}

catch (Exception err)
{
return "Source : " + err.Source + "\nMessage : " + err.Message;
}

finally
{
if (objReader != null)
{
objReader.Close();
objReader.Dispose();
}
if (objConnection != null)
{
objConnection.Close();
objConnection.Dispose();
}
}
}

}
}

_______________________

Not sure what I am doing wrong.

Thanks,

- Reena
 
HttpContext.Current.Session if you're out of the Page scope.
You could add the line

HttpSessionState Session = HttpContext.Current.Session;

into the class initialisation.

hth
Leon
 
Thanks Leon. Works.

Leon Jollans said:
HttpContext.Current.Session if you're out of the Page scope.
You could add the line

HttpSessionState Session = HttpContext.Current.Session;

into the class initialisation.

hth
Leon

Reena said:
Hi,

I am working on .NET 2003, C#. I have created a class file and getting...

The name 'Session' does not exist in the class or namespace
'RADWebV5.RADAsp.Class.Connection'

Connection.cs code....

using System;
using System.Data.OracleClient;
using System.Web.SessionState;

namespace RADWebV5.RADAsp.Class
{
/// <summary>
/// Summary description for Connection.
/// </summary>
public class Connection
{
public Connection()
{
//
// TODO: Add constructor logic here
//
}

public static string LogOn(string UserID, string Password)
{
OracleConnection objConnection = null;
OracleDataReader objReader = null;

try
{
Session["UserID"] = UserID;
Session["Password"] = Password;
}

catch (Exception err)
{
return "Source : " + err.Source + "\nMessage : " + err.Message;
}

finally
{
if (objReader != null)
{
objReader.Close();
objReader.Dispose();
}
if (objConnection != null)
{
objConnection.Close();
objConnection.Dispose();
}
}
}

}
}

_______________________

Not sure what I am doing wrong.

Thanks,

- Reena
 
Back
Top