Hi marutivsn,
First, add connection string in Web.Config file in ASP.Net Web Forms Application.
If you are working with Windows applications, then use App.Config.
For more details on how to add connection string, please refer below articles.
ASP.Net Web Forms:
ASP.Net Windows:
Connecting Database in Code using VB.Net
You need to make use of SqlConnection and SqlCommand class as they are use for connecting your application to server or database.
'Specifying Sql query
Dim query As String = "<SQL QUERY>"
'Fethced database or server details from Web.Config or App.Config.
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
'Making connection to the database or server
Using con As SqlConnection = New SqlConnection(constr)
'For executing Sql query
Using cmd As SqlCommand = New SqlCommand(query, con)
'Perform Database Operations here.
End Using
End Using
For practical example, refer my article