SQL Server Developer Center >
SQL Server Forums
>
.NET Framework inside SQL Server
>
Sql Server Express Multiple Connection
Sql Server Express Multiple Connection
Hi All,
I have a C# application that runs on Sql Server. The application has multiple SQLConnections to the same database. When I try to run the application on Sql Express 2005, it does not allow more than 1 SQLConnection.Is there anything I can do to fix this?
Any insight is most appreciated.
Mark G
Answers
- SQL Server Express should allow multiple connections. Is your database perhaps in single user mode? What error are you getting?
Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/- Marked As Answer byJian KangMSFT, ModeratorThursday, October 29, 2009 12:38 PM
- Hi Mark.
Could you please elaborate a bit? How do you connect to the database? What is the connection string?
If the connection string looks as follows, the issue might be caused by user instance.
Please have a look at the Common Issues section in the following document:Data Source=.\SQLEXPRESS;Integrated Security=true; AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
SQL Server 2005 Express Edition User Instances
The other main issue with user instances occurs because SQL Server opens database files with exclusive access. This is necessary because SQL Server manages the locking of the database data in its memory. Thus, if more than one SQL Server instance has the same file open, there is the potential for data corruption. If two different user instances use the same database file, one instance must close the file before the other instance can open it. There are two common ways to close database files, as follows.
Alternatively, you can attach the database in SQL Server Management Studio and modify the connection strings as follows so that multiple clients can connect to the same database.
Server=.\ SQLEXPRESS;Database=myDataBase;Trusted_Connection=True;
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byJian KangMSFT, ModeratorThursday, October 29, 2009 12:38 PM
All Replies
- SQL Server Express should allow multiple connections. Is your database perhaps in single user mode? What error are you getting?
Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/- Marked As Answer byJian KangMSFT, ModeratorThursday, October 29, 2009 12:38 PM
- Hi Mark.
Could you please elaborate a bit? How do you connect to the database? What is the connection string?
If the connection string looks as follows, the issue might be caused by user instance.
Please have a look at the Common Issues section in the following document:Data Source=.\SQLEXPRESS;Integrated Security=true; AttachDbFilename=|DataDirectory|\mydb.mdf;User Instance=true;
SQL Server 2005 Express Edition User Instances
The other main issue with user instances occurs because SQL Server opens database files with exclusive access. This is necessary because SQL Server manages the locking of the database data in its memory. Thus, if more than one SQL Server instance has the same file open, there is the potential for data corruption. If two different user instances use the same database file, one instance must close the file before the other instance can open it. There are two common ways to close database files, as follows.
Alternatively, you can attach the database in SQL Server Management Studio and modify the connection strings as follows so that multiple clients can connect to the same database.
Server=.\ SQLEXPRESS;Database=myDataBase;Trusted_Connection=True;
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byJian KangMSFT, ModeratorThursday, October 29, 2009 12:38 PM


