Groups | Blog | Home
all groups > sql server connect > december 2006 >

sql server connect : SQL Server 2005 Express - only one connection


Dennis Ginley
12/12/2006 10:45:51 PM
Hi, all,

I have SQL Server 2005 Express and Visual Studio 2005 installed on the same
machine. I created a database using Management Studio Express, and a C#
application to access the database. Here's the problem:

I can connect to the database via either the C# application or the
Management Studio, but not both. If I connect first via Management Studio,
when I then open Visual Studio and the the Server Explorer, the database
name has a red X next to it and I can't establish a connection.

If I connect first via my C# application, I can't even open the database in
Management Studio. There, the database does not have the plus sign to its
left, so it can't be expanded to show tables, etc. If I right click on the
db name and click Properties, I get a dialog with the following messages:
"Cannot show requested dialog.(Microsoft.SqlServer.Express.SqlMgmt)
An exception occurred while executing a Transact-SQL statement or batch.
(Microsoft.SqlServer.Express.ConnectionInfo)
Database 'Name' cannot be opened due to inaccessible files or insufficient
memory or disk space. See the SQL Server errorlog for details. (Microsoft
SQL Server, Error: 945)"

Within Management Studio, all of the logs that I can find are empty, so
there's no help there. In the system event log I see this:
"FCB::Open: Operating system error 32(The process cannot access the file
because it is being used by another process.) occurred while creating or
opening file 'C:\Program Files\Microsoft SQL
Server\MSSQL.1\MSSQL\Data\MutualFunds.mdf'. Diagnose and correct the
operating system error, and retry the operation."

Based on that message, it looks like a file sharing problem, but I can't see
any setting to change to allow multiple connections to the database file.
The fix is probably something simple, so if someone could slap me upside the
head I'd really appreciate it.

Once I've connected with one method, the only way to connect with the other
method is to reboot the system.

The system is running XP Pro with SP2, in case that's important.

Thanks,
Dennis

Roger Wolter[MSFT]
12/13/2006 7:38:03 AM
This sounds like your application connects thorough a user instance
connection and SSMS is connecting through the main instance. Basically you
have two different copies of SQL Server trying to open the same file for
write and SQL Server doesn't allow that. You either need to change your
application to not specify user instance in the connection string or open up
the connection from SSMS through the user instance named pipe. There's a
better explanation of all this here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsse/html/sqlexpuserinst.asp


--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

[quoted text, click to view]

Dennis Ginley
12/13/2006 10:43:44 PM
Thank you, Walter, that was exactly my problem. I changed my connect string
to include "User Instance= False" and it fixed my problem. I can now connect
concurrently through SSMS and my app.

Dennis

[quoted text, click to view]

AddThis Social Bookmark Button