Community discussion forum

Database connection issue with IIS

Tags: asp.net, db India
  • 1 year ago

    Hi Guys,

    I created a web application on my Windows XP laptop running SQLSERVER express 2005 and visual studio 2008.

    In my web application I am using the ASPNETDB.MDF database that comes with the default membership provider. I am also using another SQL Server DB file inside my application.

    The thing is it all works great when I am launching the application from inside of Visual Studio 2008.

    2 days ago, I moved this application to IIS 5.1 that is installed on my laptop by creating a virtual directory for this web application.

    Everything works fine when I start this application from IIS until I come to the Login Page

    When I enter the username and password and hit Submit, I get this:

    Unable to open the physical file "D:\VS2008_Workspace\ShoppingCart\App_Data\aspnetdb_log.ldf". Operating system error 5: "5(Access is denied.)". An attempt to attach an auto-named database for file D:\VS2008_Workspace\ShoppingCart\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

    Here is the configuration information for the ASPNETDB database: ( from web.config file)

    <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;Integrated Security=True;User Instance=true"

    providerName="System.Data.SqlClient" />

     

    Can anyone point me in the right direction ?

     

  • 1 year ago

    [quote]The thing is it all works great when I am launching the application from inside of Visual Studio 2008.[/quote]

    ...but it deosn't work when you are using IIS. 

    I figure this may be a file permissions / trust issue.I'd probably have a look at the security that you have on your files/folders and whether the asp process is being allowed access to your application.

    Worth checking this.

    As an 'aside', do you normally login to your machine to develop as an "Administrator" or a normal 'user'?

    Joe 

  • 1 year ago

    Hi Joe,

     Thanks for posting a reply to this.

    The problem has been resolved. I had posted this in another forum and thanks to another poster's kindness, I finally got a resolution to this issue.

     Here is the link:

    http://forums.asp.net/t/1264511.aspx

    The problem was that I needed to add the Initial Catalog to the configuration string.

    I also deleted the log file (.LDF) . That got it to work.

    Regarding the permissions, I suspect that might have been a problem ... because initially I had not given permissions on the log file (.LDF) to the ASPNET user. But after i deleted the LOG file and reran my application from IIS, it worked.

    I normally login to my machine as a "power" user (with plenty of permissions etc) , not an administrator .

    Thanks for getting back, I really appreciate it.

  • 1 year ago

    Excellent.... Glad to hear you got it sorted. Doh! .. should have known to check the connection string first .. usually the simplest things trip us all up.

    Thanks for the link - I'm sure myself and others will be able to use it in the future :D

    Joe 

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!