Get ConnectionString For SQL Server

Introduction 

We always have chance to use connection strings, such as in an application. When we need it, the first idea is to acquire it from SQL Server Managerment Studio. However, it seems we cannot. 

This article will introduce several ways that we can get connection strings easily. The article will cover the following:

  • Introduction
  • A - Get Connection string by SSMS (SQL Server Management Studio) --- no way
  • B - Get Connection string from online reference or generator
  • C - Get Connection String by Visual Studio, Server Explorer
  • D - Get Conenction String by Microsoft Universal Data Link file (xxx.udl)

A - Get Connection String by SSMS

Although the first expection is to get Connection String from SSMS, but actually, we cannot. Open SSMS, right click a Database Connection => Properties.

Open the Server Properties Window. This is most possible place where I might get the database Connection String. However, we have all parameters available, but we cannot see the whole connection string.

Click the link "View Connection Properties" on the left panel of this Window:

As before, I can get all parameters, but not the connection string.

B - Get Connection String by online Reference or Generator

online Reference:

From the Web, we can check and get the connection string we need, such as in:

We can get connection string like this:

However, we do not have chance to test the connection string.

Online Generator:

We can use an online Connection String generator, such as:

To generate a Connection String by your parameters:

You can get a real and ready connection string using your specifc parameters, but stil cannot make a test.

C - Get Connection String by Visual Studio's Server Explorer

In Visual Studio IDE, Click View => Server Explorer:

In the Server Explorer, click the Connect to Database icon:

To add a connection:

In this way, we can test if the connection is working.

Finally, click the Advanced Button. Then we can get the connection string at the bottom of the Advanced Properties Window.

Otherwise, after creating the connection, right click => Properties:

In Properties Window, we will see the ConnectionString there too:

D - Get Connection String by Microsoft Universal Data Link file (xxx.udl)

We can create a Data.udl file in the computer:

Double click the Data.udl file, and set up the connection:

Click the Test Connection button:

Close the created connection, and open the Data.udl file by another editor, such as VS Code:

We will see the connection string:

 

Reference


Similar Articles