I assume the connection string contains something like "attachfilename=etc", right?
instead, you should NOT use that, but keep the database attached, and just connect to the server.
Main Topics
Browse All TopicsI have a VS2008 ASP. NET application that uses a SQL Server Express 2008 database.
I also wrote a VS2008 WinForms application that shares that database to perform various maintenance functions.
All works well in my development environment. While my ASP.NET application is active, I can run my WinForms application with no problem.
On the REAL server, however (using IIS), I can run one or the other, but not both at the same time.
I get various error messages such as "System.Data.SqlClient.Sql
I'm guessing the upgrading to full SQL Server would resolve this, but that's pretty expensive.
Can anyone shed some light on this issue?
HBH
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks for your help!
The Web.Config file statement is:
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integr
The Connection statement from my WinForms application that accesses the same database is:
DSN = "Data Source=.\SQLEXPRESS;Attach
HBH
that's what I thought: the attachdbfilename part.
so, instead, attach the db permanently to the sql server instance, and connect
by replacing the attachdbfilename=...; part by this:
database=spotnote;
(assuming that you attach the db with that name).
to attach the db permamently, use the stored procedure sp_attachdb
Thanks for the help, but I'm still getting a database conflict on the IIS SERVER, but not on my DEV system. If web application is NOT running, then the WinForms application works fine.
The web application and the WinForms application are both running on the same server (the IIS server).
The connection for my web project (in Web.Config) is:
<connectionStrings>
<clear/>
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integr
<add name="SpotNoteDataBase" connectionString="data source=.\SQLEXPRESS;Integr
</connectionStrings>
The connection for my WinForms project is:
DSN = "Data Source=.\SQLEXPRESS;databa
The error message I receive when my web application is running and I try to start my desktop application is:
System.Data.SqlClient.SqlE
Login failed for user 'JD-DESKTOP\James'.
at System.Data.SqlClient.SqlI
To reiterate, on the IIS server, either one works alone, but not together. On my DEV system they work together.
Thanks again for any help you can provide.
HBH
Thanks again for all of your help on this.
I've determined what the issue is.
It's related to the fact that we're using SQL Server Express.
SQL Server Express allows up to 10 connections, but only 1 application can attach to the database files at a time.
Thus once IIS opens the DB, no other application can access it.
The only solution would appear to switch to one of the other editions of SQL Server.
HBH
Helmar0, that's incorrect.
SQL Server Express allows an unlimitted number of connections. Any number of users can connect to the same database at one time.
There is no need to upgrade. You just have to attach the database ONCE only using the sp_attach_db proc. From then on use the correct connection string referencing the database NAME. Do not use the file name syntax. Angel has already given the same advice. You can find more connection string examples here:
http://www.connectionstrin
Forgive me, but I guess I must be dense.
I've tried all combinations of connection strings for both my ASP.NET application and my WinForms application with no luck.
I don't understand how to use the "sp_attach_db proc" you're suggesting.
Is this something that goes in the connection string?
Is this something I do from my ASP.NET and WinForm application? If so, then how?
For example, currently my WinForm application:
DSN = "Data Source=.\SQLEXPRESS;Attach
Dim dB As SqlConnection = New SqlConnection(DSN) ' Connection object
dB.Open()
How would this (and the similar code in my ASP.NET appliction) change?
HBH
Business Accounts
Answer for Membership
by: tigin44Posted on 2009-01-01 at 13:19:59ID: 23276379
do all your applications access to the same database server?