Connection string in web.config

aliweb

Active member
Joined
Sep 14, 2005
Messages
40
Programming Experience
3-5
Hello,

By default this is written in web.config

VB.NET:
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#800000]sessionState[/COLOR][/SIZE][SIZE=2][COLOR=#ff00ff] 
[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]mode[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="InProc"
[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]stateConnectionString[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="tcpip=127.0.0.1:42424"
[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]sqlConnectionString[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="data source=127.0.0.1;Trusted_Connection=yes"
[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]cookieless[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="false"[/COLOR][/SIZE][SIZE=2][COLOR=#ff00ff] 
[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]timeout[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]="20"[/COLOR][/SIZE][SIZE=2][COLOR=#ff00ff] 
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]/>
[/COLOR][/SIZE]

My question is how can I use this sqlConnectionString defined here in my web page? I mean when I tried to print it using

Response.Write (session("sqlConnectionString"))
and
Response.Write (sqlConnectionString)

but it didn't work. So what is the purpose of it and how can I use it in y web page.
 
When I generate a connection string it comes up with this:


VB.NET:
	<connectionStrings>
		<add name="DatabaseConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
	</connectionStrings>

and to get the connectionstring i do

VB.NET:
Response.Write(ConfigurationManager.ConnectionStrings("DatabaseConnectionString1"))
 
Back
Top