“Server” vs “Data Source” in connection string

2019-01-14 10:16发布

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?

3条回答
SAY GOODBYE
2楼-- · 2019-01-14 10:44

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
查看更多
Melony?
3楼-- · 2019-01-14 10:46

... 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

查看更多
该账号已被封号
4楼-- · 2019-01-14 10:59

They are synonymous - you can use either one.

That is - as far as the framework is concerned, they are the same.

查看更多
登录 后发表回答