Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initial Catalog vs AttachDbFilename in Connection string ado.net

When it comes to Ado.net connection strings , I have used Initial Catalog attributes at most of my projects.

But now most of the downloaded sample projects widely use AttachDbFilename attributes at connection string.

I know both ways can connect to database correctly. But what i really would like to know is that is there any differences.

Because now I still could not decide which way I really need to follow when it comes to my MVC project which is really need to provide for multiple requests at the same time.

Every suggestion will be really appreciated.

like image 486
Frank Myat Thu Avatar asked Feb 17 '12 08:02

Frank Myat Thu


People also ask

What does initial catalog mean in connection string?

Initial Catalog is the name of the database to be used by the connection string, which is located on the server that was specified in the Data Source part of the connection string.

What is the difference between initial catalog and database?

The only difference is the name. These can be used interchangeably.

What is AttachDBFileName in connection string?

Using AttachDBFileName and User Instance means that SQL Server is creating a special copy of that database file for use by your program. If you have two different programs using that same connection string, they get two entirely different copies of the database.

What are the different parts of a connection string?

The connection string may include attributes such as the name of the driver, server and database, as well as security information such as user name and password.


1 Answers

AttachDbFilename is when you are working with SQL Express or SQL CE locally. It allows you to specify directly the name of the .MDB database file. It's used locally during development.

When you ship your application into production and a SQL Server instance you use Initial Catalog to specify the database name. You don't bother with filenames => that's handled by SQL Server.

like image 75
Darin Dimitrov Avatar answered Nov 03 '22 00:11

Darin Dimitrov