A
Alex
Hi,
I have an aspx file that creates a custom class object and calls a
method which should return a DataSet. It throws a:
Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the required
permission please contact your system administrator or change the
application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the
permission of type System.Data.SqlClient.SqlClientPermission,
System.Data, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.
Error.
When the methods from DB.cs is included in the aspx file it works
ok!!!
What is the problem? And how can I resolve it so that I have code
seperationg.
Here are the files in more detail:
aspx page:
<%@ Import Namespace="DBAccess" %>
protected void Page_Load(Object Src, EventArgs E)
{
DB db = new DB();
DataSet ds = db.GetDataSet("spu_Marketer", "Marketer");
MyDataGrid.DataSource=ds.Tables["Marketer"].DefaultView;
MyDataGrid.DataBind();
AnotherDataGrid.DataSource=ds.Tables["Marketer"].DefaultView;
AnotherDataGrid.DataBind();
}
DB.cs
namespace DBAccess
{
/// <summary>
/// ADO.NET data access using the SQL Server Managed Provider.
/// </summary>
public class DB
{
// connection to data source
private SqlConnection con;
private void OpenCon()
{
if (con == null)
{
con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
con.Open();
}
}
public DataSet GetDataSet(string procName, string sString)
{
OpenCon();
SqlDataAdapter sdc = new SqlDataAdapter(procName, con);
sdc.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
sdc.Fill(ds, sString);
return ds;
}
}
}
I have an aspx file that creates a custom class object and calls a
method which should return a DataSet. It throws a:
Description: The application attempted to perform an operation not
allowed by the security policy. To grant this application the required
permission please contact your system administrator or change the
application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the
permission of type System.Data.SqlClient.SqlClientPermission,
System.Data, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.
Error.
When the methods from DB.cs is included in the aspx file it works
ok!!!
What is the problem? And how can I resolve it so that I have code
seperationg.
Here are the files in more detail:
aspx page:
<%@ Import Namespace="DBAccess" %>
protected void Page_Load(Object Src, EventArgs E)
{
DB db = new DB();
DataSet ds = db.GetDataSet("spu_Marketer", "Marketer");
MyDataGrid.DataSource=ds.Tables["Marketer"].DefaultView;
MyDataGrid.DataBind();
AnotherDataGrid.DataSource=ds.Tables["Marketer"].DefaultView;
AnotherDataGrid.DataBind();
}
DB.cs
namespace DBAccess
{
/// <summary>
/// ADO.NET data access using the SQL Server Managed Provider.
/// </summary>
public class DB
{
// connection to data source
private SqlConnection con;
private void OpenCon()
{
if (con == null)
{
con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
con.Open();
}
}
public DataSet GetDataSet(string procName, string sString)
{
OpenCon();
SqlDataAdapter sdc = new SqlDataAdapter(procName, con);
sdc.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
sdc.Fill(ds, sString);
return ds;
}
}
}