aspnet connections

aspnet connections

Old forum URL: forums.lhotka.net/forums/t/3709.aspx


jhw posted on Sunday, October 14, 2007

I have a web application that cannot conect to the sql database.

 

I have a web.config connetions string:

<add name="Thompson" connectionString="User Id=sa;Data Source=jhw-laptop\MyDatabse;Integrated Security=True;User Instance=False; pwd=MyPassword; initial catalog=Thompson;" providerName="System.Data.SqlClient" />

This is basically copied from the vb2005 book. The connection string works good in app.config in a console app for testing. For the 1st week it worked good in the web app. Now I can no longer log into the database as it is trying to use the aspnet account.

I could add the aspnet user to the database and add all the permissions, but should I have to do this? Shouldn't the web application be accessing the database through the specified config username and password, instead of using the aspnet account.

It is strange that it worked for a week before failing because login fails for aspnet account.

 

Heath

 

jhw replied on Sunday, October 14, 2007

I think it failed when I added the asp:loginStatus and the assoƧ PTMembership provider.. Could it be that I am using a localhost for development, and have not moved the database files to the app_data directory? When Rocky said: move the database file to the app_data, does that mean moving the mdf and ldf files to the app_data folder and changing the file path in sql server?

So I moved the database to the app_data folder and used the attach database system in web.config. It is still trying to connect with the aspnet account. I know this because it gives me an execute denied error as I added the aspnet account to the database, but did not give it any permissions.

So should it be trying to access the database via aspnet account? My understanding is that is should be through the account in the connectionstring of web.config. So why is it trying to use aspnet?

Thanks

Heath

RockfordLhotka replied on Sunday, October 14, 2007

I'd recommend adding another database file to your web project using Visual Studio. Then you can see the connection string it creates on your behalf and use it as a template for your connection string to your own database.

Also, it is possible that there's an NTFS folder permission issue. The ASPNET account needs write access to your app_data folder or it can't write to your database.

Copyright (c) Marimer LLC