Henry,
VS 2005 (.NET 2.0) introduced a new connectionStrings section to the
app.config (web.config).
http://msdn2.microsoft.com/en-us/library/bf7sd233.aspx You can access it via the ConnectionStrings property:
http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.connectionstrings.aspx --
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net [quoted text, click to view] "Henry" <nom@il.com> wrote in message
news:eyhmq$rvGHA.5088@TK2MSFTNGP06.phx.gbl...
| Hi
|
| Is it possible to access connections strings from web.config from within
the
| application?
|
| I'm using VS2005 and VB
|
|
| Sub LogVisit(ByVal network As String, ByVal IsValidNetwork As Boolean)
| Dim sqlCmd As SqlCommand
| Dim sqlcn As SqlConnection
|
| 'this on works, it's a public variable
| sqlcn = New SqlConnection(c_cnstr)
|
| 'this on doesn't work, it's a connectionstring from web.config
| 'sqlcn = New SqlConnection(FSBConnectionString)
|
|
| sqlCmd = New SqlCommand(GetCommand( _
| Request.PhysicalApplicationPath + c_scriptDirectory +
| "c_insLogVisit.sql"), sqlcn)
| sqlcn.Open()
| Try
|
| 'bla bla bla
|
| Finally
| sqlcn.Close()
| End Try
|
| End Sub
|
|