Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Server" vs "Data Source" in connection string

I'm new to SqlServer, right now I have SqlLocalDb installed to work locally. Good, but I can see two connection strings typically and both works:

Data Source=(localdb)\v11.0;Integrated Security=true;

and

Server=(localdb)\v11.0;Integrated Security=true;

What exact difference is there between the two?

like image 565
nawfal Avatar asked Oct 12 '22 16:10

nawfal


People also ask

What is the difference between data source and server in connection string?

They are synonymous - you can use either one. That is - as far as the framework is concerned, they are the same. I've been googlearching for the reason for the range of equivalent keywords in the connection strings.

What is connection string data source?

A data source connection specifies the parameters needed to connect to a database, such as the location of the database and the timeout duration. These parameters form a connection string for the data source. You can include authentication information for the database in the data source connection by creating a signon.

What is a server connection string?

The connection string is an expression that contains the parameters required for the applications to connect a database server. In terms of SQL Server, connection strings include the server instance, database name, authentication details, and some other settings to communicate with the database server.

What is data source in SQL connection?

Data source is the name of the MS SQL server instance you are connecting to and Inital Catalog is the database name you want to connect to. EG: You have a default instance of MS SQL server Express and a database named Northwind.


2 Answers

For the full list of all of the connection string keywords, including those that are entirely synonymous, please refer to the SqlConnection.ConnectionString documentation:

These are all entirely equivalent:

  • Data Source
  • Server
  • Address
  • Addr
  • Network Address
like image 146
Damien_The_Unbeliever Avatar answered Oct 17 '22 13:10

Damien_The_Unbeliever


... There is no difference between Server and Data Source as they represent the same thing for SQL Server : the full name of the SQL Server instance with the syntax "MyComputerName\MyShortInstanceName" , potentially including the port used by the SQL Server instance to communicate.

Reference: http://social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/7e3cd9b2-4eed-4103-a07a-5ca2cd33bd21

like image 20
Exel Gamboa Avatar answered Oct 17 '22 12:10

Exel Gamboa