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.
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.
The only difference is the name. These can be used interchangeably.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With