connecting to sql server ok with visual, KO with iis

Posts   
 
    
zedine
User
Posts: 8
Joined: 17-Jun-2006
# Posted on: 24-Oct-2006 18:08:50   

Hello,

we are having an issue in a project that is working fine in developpement under visual studio 2005. my project is working fine when developping with visual studio but can't do anything with database with iis or with a binary.

a simple ccc.GetMulti(null); or cce.Save(); does not work at all. but it is working perfectly when i build the project with visual studio ...

is there anything i need to confgure in sql server or in iis to make it works ??

btw, i am also working with the entlib, and same issue, working fine with vs, not working at all with iis ...

any clue ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39894
Joined: 17-Aug-2003
# Posted on: 24-Oct-2006 18:58:09   

What's the error code? I don't quite follow what you mean exactly by it's not working: you can't connect to the database? What's the db type? If you're using integrated security with sqlserver, is the user under which the website runs (e.g. networkuser, ASPNET) added to the sqlserver instance and catalog?

Frans Bouma | Lead developer LLBLGen Pro
zedine
User
Posts: 8
Joined: 17-Jun-2006
# Posted on: 24-Oct-2006 22:18:22   

i am quite sure it is web.config problem. can't get the error code since it is only when i'm in production mode, not under visual. dabase type is many tables under sql server. yes, sql server and iis are under the same server, and yes, i added ASPNET to users in the db in sql server.

question is, when making a release, do i need to change something in web.config or app.config ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39894
Joined: 17-Aug-2003
# Posted on: 24-Oct-2006 23:59:19   

in the .config file of your application, so in the web.config file.

What kind of error do you get? Please be somewhat more specific, as you didn't provide that much information, so I don't know if the connection can't be established, or that a query fails because the catalog name is different etc...

Frans Bouma | Lead developer LLBLGen Pro
zedine
User
Posts: 8
Joined: 17-Jun-2006
# Posted on: 25-Oct-2006 04:22:49   

ok, here is the error for a .save():

[SqlException (0x80131904): INSERT permission denied on object 'CrawlConfig', database 'netbooster', schema 'dbo'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +857386
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +734998
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
   System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +886
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
   System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
   System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
   SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() +324

[ORMQueryExecutionException: An exception was caught during the execution of an action query: INSERT permission denied on object 'CrawlConfig', database 'netbooster', schema 'dbo'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.]
   SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() +585
   SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute() +73
   SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteActionQuery(IActionQuery queryToExecute, ITransaction containingTransaction) +64
   SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.AddNew(IEntityFields fields, ITransaction containingTransaction) +220
   llblec.EntityClasses.CrawlConfigEntity.InsertEntity() in J:\tmp\netbooster\03 code\EasyCrawler\llblec\EntityClasses\CrawlConfigEntity.cs:994
   SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PersistQueue(List`1 queueToPersist, Boolean insertActions, ITransaction transactionToUse) +573
   SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse) +668
   llblec.EntityClasses.CrawlConfigEntity.Save(IPredicate updateRestriction, Boolean recurse) in J:\tmp\netbooster\03 code\EasyCrawler\llblec\EntityClasses\CrawlConfigEntity.cs:200
   SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save() +94
   Testpages_addCrawl.refreshCrawlConfigButton_Click(Object sender, EventArgs e) in d:\netbooster\03 code\EasyCrawler\Testpages\addCrawl.aspx.cs:43
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

so it is an acces denied. but i added ASPNET in sql server db users. Isn't that the user that make the .save() ??

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-Oct-2006 10:02:48   

so it is an acces denied. but i added ASPNET in sql server db users. Isn't that the user that make the .save() ??

Are you using another username / password in the connection string in the web.config?

Also adding a user to SQL server doesn't grant him permissions. You should set the permissions/roles of the user.

zedine
User
Posts: 8
Joined: 17-Jun-2006
# Posted on: 25-Oct-2006 13:19:21   

extract of my web.config:

    <appSettings>
        <add key="Main.ConnectionString" value="data source=localhost;initial catalog=netbooster;integrated security=SSPI;persist security info=False;packet size=4096" />
    </appSettings>
    <authentication mode="Windows" />

and, i did not simply added the user, i checked all boxes when added ASPNET.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-Oct-2006 18:17:08   

If you are using Trusted Connection, then make sure your web application does not use another windows account (impersonation) -> check the web.config file for <authentication> & <identity> tags under the <system.web> tag.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39894
Joined: 17-Aug-2003
# Posted on: 25-Oct-2006 19:14:37   

I think the core reason is that the ASPNET user might have been added to sqlserver, but that the user doesn't have any access rights to the catalog (i.e. isn't in the public role) and as Walaa said, doesn't have any access rights on the tables/views used.

Frans Bouma | Lead developer LLBLGen Pro
zedine
User
Posts: 8
Joined: 17-Jun-2006
# Posted on: 26-Oct-2006 01:12:03   

ok, thanks for your help, both simple_smile you were right Otis, it was the access right of ASPNET. i was checking all role members and it wasn't working (don't ask me why) when with only db_datareader and db_datawriter, it's ok simple_smile one other question though ... i have a binary inside this project which is using a library, which is also available for a web project. and i was going to ask what make the binary also able to write and read in db, but it seems aspnet also give it the rights simple_smile

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Oct-2006 10:21:29   

Yes those binaries are running within the same application context using the same user credentials of the application.