[dba-VB] Connection String Anomoly

David Emerson newsgrps at dalyn.co.nz
Wed Nov 23 21:10:22 CST 2011


I have used the round bracket syntax in another project and it worked 
ok.  That project was complete in itself.

This project is an add on to another one being developed by a 
separate developer.  I don't have access to the complete project 
except when it is installed on a test server.  Even then all I can do 
is put my files in place and see how they run.  The file locations 
are different from other projects I have done but they seem to work 
except for this connection string.

Since everything else works it may be some time before I can spending 
more time playing around with it.

Thanks for the suggestion.

David

At 24/11/2011, Doug Steele wrote:
>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 ______________________________**_________________




More information about the dba-VB mailing list