c# - Permissions on database varying with run -


this question not duplicate, when use accepted answer of possible duplicate causes problem.

i have windows web forms app in asp.net, using sql server.

i'm using stored procedures , dynamic data binding. problem is, connect, throw message, next time try connect.

http error 403.14 - forbidden web server configured not list contents of directory. 

i've followed suggestions on page.

i have change connection string connect again. can use connection string exists, need stuff around. i'm wondering when stop running program, if i'm not cleaning resources, perhaps causing this?

const string constring = "data source=localhost;initial catalog=cart1;integrated security=true";  public static void selectproductsfromcat(gridview gv, int id)     {         // sqlconnection.         sqlconnection con = new sqlconnection(constring);         // create new command , parameterise.         sqlcommand cmd = new sqlcommand();         cmd.commandtype = commandtype.storedprocedure;         cmd.commandtext = "selectprodfromcat";         cmd.parameters.add("@catid", sqldbtype.int).value = id;         sqldataadapter da = new sqldataadapter(cmd);          cmd.connection = con;         try         {             // open connection , bind data gui.             con.open();            da.fill(ds);             if (ds.tables.count > 0)             {                 gv.datasource = ds.tables[0];                 gv.allowpaging = true;                 gv.databind();             }         }         catch (exception ex)         {             throw ex;         }                 {             con.close();             con.dispose();         }     } 

i'm sorry if there not enough information here, i'm not sure causing problem.

basically wondering cause connect , not others?

edit

when added solution question the web server configured not list contents of directory. asp.net vs 2012 error?

<system.webserver>     <modules runallmanagedmodulesforallrequests="true"/> </system.webserver> 

it caused error happen immediately.

edit

web configuration:

<?xml version="1.0" encoding="utf-8"?>  <configuration>   <connectionstrings>     <add name="cart1connectionstring" connectionstring="data source=localhost;initial catalog=cart1;integrated security=true"   providername="system.data.sqlclient" /> </connectionstrings>   <system.web>      <compilation debug="true" targetframework="4.5" />      <httpruntime targetframework="4.5" />   </system.web> </configuration> 


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -