First you need to edit your 'web.config'. This file should look something like below:-
="1.0"
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=servername;Initial
Catalog=databasename;Persist Security Info=True;User Id=username;Password=password;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Then in your asp.net vb file use the below:-
Then the below is where you link to the connection string in the 'web.config' file:-
SQLConnection MyConnection = default(SQLConnection);
MyConnection = new SqlConnection();
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString;
I hope this will help you.