locked
Where is the connection string for the ASPNETDB.mdf RRS feed

  • Question

  • User709978785 posted

    I have a file system project that I moved from the VS Web server to IIS now it will not run; I receive the following message:

    An attempt to attach an auto-named database for file C:\Documents and Settings\Server\My Documents\Visual Studio 2005\WebSites\MyProject\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.

    The file is in the App_Data folder of my project, and it is the only one on the system.

    Does anyone know where this database keeps its connection string? It is not in my web config file.

    Any help is appreciated.

    Monday, January 8, 2007 10:31 PM

All replies

  • User-503940700 posted

    Hi,

    Go to IIS->your Virtual Directory or website->right click->Properties->ASP.NET tab->Edit configuration. There you can see all your connection strings.

    Regarding the error message, make sure that App_Data folder is readable/writable by the ASPNET user. Right click the folder, go to securities and give permissions to the ASPNET user.

    HTH,

    Vivek

    Tuesday, January 9, 2007 12:20 AM
  • User709978785 posted

    This is the exception I get when my app tries to run:

    An attempt to attach an auto-named database for file C:\Documents and Settings\MyServer\My Documents\Visual Studio 2005\WebSites\MyApplication\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.

     Also I looked at the connection manager and this is what I found:

    LocalSQLServer: data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true

    What is meant by LocalSqlServer?

    My database is also listed, however, it has the connection string that is in my web config file.

    Should the aspnetdb be listed in my web config also?

    Tuesday, January 9, 2007 9:59 AM
  • User-503940700 posted

    LocalSqlServer is the default built in connection string to be used by the ASPNET runtime while creating the default DB (aspnetdb.mdf) at runtime to be used by the membership API. If you dont want to use the membeship API, or want to use your own DB for it, then you can remove this connection string by either deleting this entry or by adding a <remove> tag in your web.config before the conenction strings section.

    Check this blog for details:

    http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

    Hope this helps,

    Vivek

    Tuesday, January 9, 2007 1:54 PM
  • User709978785 posted

    I want to use my aspnetdb, my problem is that I get the error message I posted earlier so I was just thinking it has something to do with the connection string.

    Does anyone have any suggestions as to why I get the message?

    An attempt to attach an auto-named database for file C:\Documents and Settings\MyServer\My Documents\Visual Studio 2005\WebSites\MyApplication\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.

    I have no other aspnetdb.mdf files in the project.

    It runs fine if I switch over to the ASP.NET Developer Server.

    I appreciate any help on this!!!!

     

     

    Tuesday, January 9, 2007 2:09 PM
  • User-503940700 posted

    Did you give read/write permissions to the app_data folder as I mentioned earlier? Please check the last section of this article for the details on the same:

    http://www.hkvstore.com/aspnetmaker/doc/aspnet2primer.htm

    HTH,

    Vivek

    Tuesday, January 9, 2007 2:21 PM
  • User709978785 posted
    I looked but there is no Security Tab. What does this mean?
    Tuesday, January 9, 2007 2:36 PM
  • User-503940700 posted

    Check out this blog I wrote sometime back:

    http://geekswithblogs.net/vivek/archive/2006/12/27/102099.aspx

    Hope this helps,

    Vivek

    Tuesday, January 9, 2007 3:01 PM
  • User709978785 posted

    First I should say that I really apreciate your help!

    I made the changes from your blog, still getting the same message.

    This is so frustrating!!!

    I looked and my virtual directory is not in the Inetpub\wwwroot\, does make a difference for how we are trying to do things here?

    I created a virtual directory from IIS and it does show in the IIS manager.

    Just reaching for straws now.

    I appreciate any thoughts or suggestions.

    Tuesday, January 9, 2007 3:49 PM
  • User-503940700 posted

    Virtual directory should not make a difference. Also you need not put your project in Inetpub/wwwroot.

    Try giving read/write permissions to everyone on the App_Data folder for the time being. If that too does not work, then check if your SQL Server 2005 Express is running or not and the connection string is configured properly. I hope you have SQL server express installed and not SQL server 2005.

    Vivek

    Wednesday, January 10, 2007 1:23 AM
  • User555306248 posted

    Just go to My Computer->Tools->View

    then uncheck the last option "Use Simple File Sharing"

    Then try it...You will get Security tab.

    Thursday, February 8, 2007 7:11 AM
  • User-541571482 posted

    OK,  here ist is sept 2009, and i am haveing the same issue.   several days tring to figure out why it works on my vista and xp machine but will not work when published on my host  webhostforasp.net. 

    Did you get it solved and can youshare your results?



    Sunday, September 20, 2009 11:22 AM
  • User-434868552 posted

    Please define more clearly "the same issue".

    If you are deploying by using a hosting service
    and your message is still saying
    C:\Documents and Settings\Server\My Documents\Visual Studio 2005\WebSites\MyProject\App_Data\aspnetdb.mdf
    it follows you will have difficulty.

    Your remote path will be different.

    If will not likely ever be C:\Documents and Settings\ ...

    Example:

    When I deploy to IIS6, I create a folder like
                    c:\xyz\myapp

    I publish to my own hard drive first in c:\myasp\myappPublish.

    I ftp the files from c:\myasp\myappPublish to c:\xyz\myapp.
    (The first c: drive is my local c: drive; the second drive is the servers c: drive.

    I run inetmgr, right click ...\Web Sites\Default Web Site\ and choose
       New, Virtual Directory... and navigate to c:\xyz\myapp.

    It might help you get a useful answer if you could describe your
    deployment process with substantial detail.


    Regards,
    Gerry (Lowry)

    Sunday, September 27, 2009 5:32 PM