Doug Steele
dbdoug at gmail.com
Wed Nov 23 19:48:33 CST 2011
This may be nothing, but I checked some auto-generated code in a project of mine, and the code uses square brackets: this._connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["RescoConnectionString"].ConnectionString; Have you tried setting a breakpoint in the code and seeing exactly what is returned into conn.ConnectionString? Doug On Wed, Nov 23, 2011 at 3:21 PM, David Emerson <newsgrps at dalyn.co.nz> wrote: > 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 ______________________________**_________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-vb<http://databaseadvisors.com/mailman/listinfo/dba-vb> > http://www.databaseadvisors.**com <http://www.databaseadvisors.com> > >