Connection String on Visual Studio 2013 with SQL Server 2014

801 views Asked by At

This is my connection string on my Visual Studio, my database file name is IOOP_Database

Data Source=IDEA-PC\SQLEXPRESS;Initial Catalog=IOOP_Database;Integrated Security=True

The problem is when I run this system on another laptop, there will be a error because of the connection string. Is there any way I can state my connection string as Date Source=IOOP_Database.mdf? I've also moved my mdf file to my Visual Studio project's debug folder, so the project file and the sql database file are actually together.

1

There are 1 answers

0
Ali M On BEST ANSWER

You can use AttachDbFilename property in connction strings. It has some limitations and has been advised to use that only in development environment not production.

AttachDBFilename is unique to SQL Express, it spins up a user instance of SQL Express attached to a specific DB Filename for single user mode. Database is simply the name of the database to use, it has no additional connotation. For any production server, you would most likely not be using AttachDBFilename. It is strictly useful for development and experimentation in single-user mode. from MSDN forum

Also you might find these helpful: