C# .NET - unable to attach database error

Asked By Rajasekar Kalidassan
03-Feb-12 07:30 AM
 A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. 

  I'm creating a C# windows application, with 2008 sql server management studio in one machine that'll hold the database and the clients can access the database via lan.

  how to do this, Could Someone help me?
I'm new to this kind of things..
  dipa ahuja replied to Rajasekar Kalidassan
03-Feb-12 08:35 AM

You connection string should look like...

Data Source=.\SQLEXPRESS;Database=<your database name>;Integrated Security=SSPI

The error you're getting is because VS generated a User Instance connection string.

A User Instance is a separate instance of SQL Express that is started at runtime which tries to attach the database specified for use by the application. Your database is already attached to the parent instance of SQL Express, and databases can only be attached to a single instance at a time.

By changing the connection string, you'll be using the parent instance, where the database is already attached, rather than the User Instance.

  kalpana aparnathi replied to Rajasekar Kalidassan
03-Feb-12 01:26 PM
This error is occures in Microsoft SQL Server 2005 but change into Microsoft SQL Server 2008 its works fine so do that for solution
Create New Account
help
Cannot open server 2000 file in SQL SERVER 2005 SQL Server I installed SQL SERVER 2005 replacing SQL SERVER 2000 and now I cannot open the 2000 database file. Do
replication sql 2000 - -> sql 2005 SQL Server , sql, 2005" / > Is it possible to replicate a db from sql server 2000 to sql server 2005? When I set the publications, I look this "select
SSIS for SQL Server 2005? SQL Server How do I download SSIS for SQL Server 2005? SQL Server Programming Discussions SQL Server 2005 (1) Distributed (1) Imp (1) Exp (1) E5C6F1F60688
DTS in SQL Server 2005 SQL Server With the SQL server 2005, how can I invoke DTS? Should I install 'SQL Server Business Intelligence Development Studio'? If
Where is my SQL Server 2005 ? SQL Server I installed SQL Server 2005 on my machine, but when I go to the SQL Server Management Studio and connect