Reputation: 3654
I read different way of writing of connection string in article
Can you please explain me where to use Server
and where to use Data Source
? Similarly where to use Database
and where to use Initial Catalog
. Please explain in detail. I am new in SQL Server.
Upvotes: 3
Views: 1197
Reputation: 822
You can compose a valid ADO.NET connection string using different keywords. There are a lot of aliases, for example: "Data Source" and "Server" means both the same thing. The same for "Database" and "Initial Catalog".
You can find a list of valid keywords and their aliases here: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx
Upvotes: 0
Reputation: 39095
Those connection string keywords can be used interchangeably. When ADO.Net is parsing the connection string, it will create a SqlConnectionStringBuilder
class (in case of Sql Server) and map the keywords withing the connection string to the SqlConnectionStringBuilder
properties.
For example, "data Source", "server", "address", "addr", and "network address" all map to the DataSource
property -- you can use either one of those to specify the data source. Similarly, "Initial Catalog" and "database" map to the InitialCatalog
property.
Take a look at the SqlConnectionStringBuilder class and its properties on MSDN where you can find more information on their keyword mappings.
Upvotes: 2