Ask a Question related to ASP.NET General, Design and Development.
-
Alex #1
Data Access Problem when importing custom file
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;
}
}
}
Alex Guest
-
Help importing excel file into Access DB
I need to import an excel file into an access database. I got the below code from a forum on another site, but it is not working. I get an error... -
problem in binding xml file data to datagrid xml file isgenerated through JSP file
problem it that i am creating xml file using JSP file and i want to bind DataGrid with xml file data that is created using JSP but it will not Bind... -
Problem with data access
i had a working site with iis5 winxp professional on a p4 machine. suddenly i am having problems with and the asp pages which have some updating... -
Getting data out of a text file and putting it in an Access DB
Hi All First of all I want to thank you all for your time and patience this weekend. Much appreciated. Secondly, I'm stuck with the... -
Problem importing .wav file
"Monstaa" <webforumsuser@macromedia.com> wrote in message news:bgo6oo$fn5$1@forums.macromedia.com... of wavs that I made myself (they are voice... -
S. Justin Gengo #2
Re: Data Access Problem when importing custom file
Alex,
Are you using integrated security on the sql server?
If you gave the aspnet account (or another that the web site is running
under) access to the sql server and are using integrated security it is most
likely that the user account that you are calling this code from is
different and it doesn't have access.
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"Alex" <alex@hotpop.com> wrote in message
news:c5c70ed9.0308120459.7aa264a0@posting.google.c om...SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);> 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> 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;
> }
>
> }
> }
S. Justin Gengo Guest



Reply With Quote

