This post will show you an easy way to Get SQL Server Database Connection String. Before you proceed with the steps below, please make sure you have Visual Studio installed on your machine. If not, you can download the latest Visual Studio installer here.
You might also want to check this article:
- Create Database using SQL Server Object Explorer
- Install Entity Framework Core
This are the format for a connection strings:
- Microsoft SqlClient Data Provider for SQL Server
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
- MySQL Connector/Net
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
How to Get SQL Server Connection Strings using Visual Studio
There is also another way to generate a connection string. That is by using the Visual Studio SQL Server Object Explorer. Follow the steps below.
- Open Visual Studio IDE. Navigate to the menu bar then select View » SQL Server Object Explorer.

2. A new window will be open on the left pane. This will allow you to connect to an existing SQL server in your machine. You may refer to the image below.

3. Connect to your server using the button with plus sign located at the top of the Server Object Explorer window.

4. A new window will prompt asking you what server to connect to. You may select the server you want to establish a connection with. This option will also ask you to choose an Authentication. In my case, I prefer Windows authentication. Click the connect button to proceed.
Authentication:
- Windows Authentication » This is the default authentication used by SQL Server. This uses windows user to authenticate with SQL Server.
- SQL Server Authentication » This authentication is validated with SQL Server’s master database.

5. Navigate back to the SQL Server Object Explorer window. Select the database where you want to view the connection strings. In my case, I’ll check basicfunction database connection string.

6. To view the connection string. Go to the database properties, which are located just below your solution explorer. Then find the database Connection String.

Now, Copy the connection string and paste it to your application for your application where you need database connectivity.
Summary
In this article, we have listed the default format of database connection strings. We also added a connection string for MySQL. This article also provides steps on how we can get the connection strings using the Visual Studio IDE. Hopefully, this helps. Happy coding!
Also read: Difference Between sql and plsql