David Emerson
newsgrps at dalyn.co.nz
Wed Nov 23 17:21:18 CST 2011
I am trying to understand what could be causing this to happen. I
have this code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Server.ScriptTimeout = 360
Dim conn As New SqlClient.SqlConnection
conn.ConnectionString = "data source=MySQLSource;initial
catalog=MyDataBase;user id=sa;password=mypassword"
This connection works and I can access stored procedures etc.
However, when I replace the Conn.Connection line above with this line
below it does not work
conn.ConnectionString =
System.Web.Configuration.WebConfigurationManager.ConnectionStrings(
"MyDatabaseConnection").ConnectionString
The Web.Config file has this:
<connectionStrings>
<add
name="MyDatabaseConnection"
connectionString="data
source=MySQLSource;initial catalog=MyDataBase;user id=sa;password=mypassword"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
Any ideas why this might be?
Regards
David Emerson
Dalyn Software Ltd
Wellington, New Zealand