Link to home
Create AccountLog in
Avatar of l2Bravo
l2BravoFlag for United States of America

asked on

Multiple Applications Connecting to Same SQL Server DB

I am migrating an application that used Access as a database to a SQL Server (using SQL Server Express) based application.  I have little experience with SQL Server, so I'm running into some obstacles in the migration process.  One of the obstacles is that I intend to use 2 different applications to read from/write to this database.  When deployed, these applications will be run from separate computers.  For the initial testing, I wanted to run the applications on the same computer as I did when using MS Access.  

However, while the first applications connects to the database just fine, the second application encounters an "attempt to attach an auto-named database" error.  The connection string is the same for both applications, so I assume the second application is lacking permission or there's some exclusivity involved, but I don't know how to overcome it.  The first application is not always running when the second application tries to open the database, so I would assume it's connection to the database is closed, but I could be wrong, of course.  

Thanks for any help you can offer.
Avatar of eli411
eli411

ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of l2Bravo

ASKER

Thanks.  I am a novice to SQL Server, so I borrowed a connection string from a Google search that used AttachDbFilename in it.  I changed it to Database= and it worked.  

Is there a good reason to attach a database?  My software project will basically use two different applications to make modifications to the one database.  The tables and records affected will be different for the 2 applications so they are not likely to try to change the same record at the same time, so I want both to have access to it without worrying about locking records or exclusive rights, etc.
you use attach to have a database have a temporary connection to the sql server.. otherwise the database is always connected to the server.
Just leave the database attached and don't attempt to attach with the connection string.  The reference to AttachDbFilename in the Connection string should not be used in a Production environment.