SQL Connection String in asp.net 2.0



SQL Connection String in asp.net 2.0 Creating an SQL connection string in asp.net 2.0

First you need to edit your 'web.config'. This file should look something like below:-
<?xml version="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:-
Dim MyConnection As SQLConnection
MyConnection = New SqlConnection()
MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString


Send a link to this page via email Send a link to this page via email