You can connect your .Net application to SQL Server using .Net framework data provider for SQL server i.e System.Data.SqlClient.
ServerName: Your SQL Server Name.
DatabaseName: SQL Server Database that you would like to connect.
UserName: SQL Server user name
Password: SQL Server password
con.Open(): Is used to open the database connection.
con.Close(): Is used to close the connection.
You can also add your connection string in web.config file. It's always a good practice to add connection string in web.config file instead of hardcoding it in code. The <connectionStrings> section you have to add inside <configuration> section.
Add the namespace System.Configuration, then using ConfigurationManager you can get the connection string as shown below.
Here "ConnectionString" is the name of the connection that we added in the <connectionStrings> section.