Tuesday, March 1, 2011

SQL Server database is not visible

I have installed ASP.NET application with database on our server. ASP.NET application created database using connection string below. The problem is that I do not see database in SQL Server Management Studio. I use "Windows Authentication" account to login to SQL Server. How to solve this problem? Also I see two sqlservr.exe instances in process manager.

server=(local)\SQLEXPRESS;database=bugs;Integrated Security=True;Connect Timeout=30;User Instance=True
From stackoverflow
  • Make sure you're connecting to (local)\SQLEXPRESS instance and not to the default instance.

  • Where is the stored procedure that created the database? Just because there is a connection string does not guarantee that there was a database created.

    Tomas : Database was created and my ASP.NET application use it succesfully.
  • You won't see databases created with "User Instance=True" unless you login as the exact user the database was created under, and the database has been attached.

    Given that if ASP.NET created the database it's likely it was created by Network Service then you are not going to see it at all. Whilst you could manually try to attached it as a user instance yourself, you may well end up messing up the permissions or hitting the "database already exists" problem.

    Patonza : Didn't know about user instances. Thank you :) Here's a technical article describing this feature: http://msdn.microsoft.com/en-us/library/bb264564(SQL.90).aspx
    Tomas : Exactly, it was created by Network Service(ASP.NET). I need to back-up it, how to do that?
    blowdart : You need to find out where the file *is* (probably in the App_data directory of your web application), then simply copy it after shutting down that web application.
    Tomas : The database was created using SQL script by application, it's name is "bugs", I have tried to search for files *.MDF and files which was found do not match my database.
    blowdart : And how do you know they don't match? With user instances they can end up *anywhere*. Normally the connection string specifies a path with AttachDbFileName=, otherwise it may be in :\Documents and Settings\\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS, or in the Network Service case perhaps under \Public\Local. You, as a normal user, may not even have access to it.
    Tomas : Yes, files are here, they are hidden and windows search didn't found them. I will take files and create new database with my mssql server account and change connection string in my asp.net application. Thank you for your help!

0 comments:

Post a Comment