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 .SecurityExcept ion: Request for the
permission of type System.Data.Sql Client.SqlClien tPermission,
System.Data, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9 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="DBAc cess" %>
protected void Page_Load(Objec t Src, EventArgs E)
{
DB db = new DB();
DataSet ds = db.GetDataSet(" spu_Marketer", "Marketer") ;
MyDataGrid.Data Source=ds.Table s["Marketer"].DefaultView;
MyDataGrid.Data Bind();
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(C onfigurationSet tings.AppSettin gs["ConnectionStri ng"]);
con.Open();
}
}
public DataSet GetDataSet(stri ng procName, string sString)
{
OpenCon();
SqlDataAdapter sdc = new SqlDataAdapter( procName, con);
sdc.SelectComma nd.CommandType = CommandType.Sto redProcedure;
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 .SecurityExcept ion: Request for the
permission of type System.Data.Sql Client.SqlClien tPermission,
System.Data, Version=1.0.500 0.0, Culture=neutral ,
PublicKeyToken= b77a5c561934e08 9 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="DBAc cess" %>
protected void Page_Load(Objec t Src, EventArgs E)
{
DB db = new DB();
DataSet ds = db.GetDataSet(" spu_Marketer", "Marketer") ;
MyDataGrid.Data Source=ds.Table s["Marketer"].DefaultView;
MyDataGrid.Data Bind();
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(C onfigurationSet tings.AppSettin gs["ConnectionStri ng"]);
con.Open();
}
}
public DataSet GetDataSet(stri ng procName, string sString)
{
OpenCon();
SqlDataAdapter sdc = new SqlDataAdapter( procName, con);
sdc.SelectComma nd.CommandType = CommandType.Sto redProcedure;
DataSet ds = new DataSet();
sdc.Fill(ds, sString);
return ds;
}
}
}
Comment