Programmatically changing a Data Source's connection property

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RB0135

    #1

    Programmatically changing a Data Source's connection property

    Hi,

    I hope I worded the subject correctly.

    Under VS2005, I have created the wizard to add a datasource that
    connects to my SQL2005 server. I ran through the wizard and this
    created a Dataset, a BindingSource and TableAdpater.

    I noticed in the file App.Config, it created an entry under MYSETTINGS
    for called xxxx.My.MySetti ngs.xxxConnecti onString with a connection
    string parameter.

    So far, this is great and on the development PC (mine) this works
    perfectly.

    Of course, when it goes into Production I need the server in the
    connection string to be dynamic. The reason being is the program is
    launched with args and one of the args determines which server to
    access to get the data from. Of course, the development PC is NOT one
    of those that can get the data.

    I have searched but most people seem to talk about changing the
    App.Config file (well, the XML file) yet that requires an application
    restart.

    I know that the App.Config parameter is read only, but is there anyway
    to override this and tell the Datasource to use the dynamically
    created connection string?

    Any help???

    Thanks,
    Robert

  • Mr. Arnold

    #2
    Re: Programmaticall y changing a Data Source's connection property

    >
    I know that the App.Config parameter is read only, but is there anyway
    to override this and tell the Datasource to use the dynamically
    created connection string?
    >
    The App.config is a template. The config file the program is using is called
    programname.exe .config is where the program is getting its information,
    which is derived form App.config and can be edited by any text editor.

    So, I can't see why you couldn't change the SQL Server Name to be access in
    the programname.exe .config manually based on the environment the application
    is running in like local, test, quality assurance, or production SQL server
    name based on the information supplied before the applications is deployed
    into the particular environment.

    Comment

    • Martin

      #3
      Re: Programmaticall y changing a Data Source's connection property

      Hi,

      is this what you are looking for?



      Regards,

      Martin


      "RB0135" <robear@joshie. com.auwrote in message
      news:1185331169 .915142.56090@z 28g2000prd.goog legroups.com...
      Hi,
      >
      I hope I worded the subject correctly.
      >
      Under VS2005, I have created the wizard to add a datasource that
      connects to my SQL2005 server. I ran through the wizard and this
      created a Dataset, a BindingSource and TableAdpater.
      >
      I noticed in the file App.Config, it created an entry under MYSETTINGS
      for called xxxx.My.MySetti ngs.xxxConnecti onString with a connection
      string parameter.
      >
      So far, this is great and on the development PC (mine) this works
      perfectly.
      >
      Of course, when it goes into Production I need the server in the
      connection string to be dynamic. The reason being is the program is
      launched with args and one of the args determines which server to
      access to get the data from. Of course, the development PC is NOT one
      of those that can get the data.
      >
      I have searched but most people seem to talk about changing the
      App.Config file (well, the XML file) yet that requires an application
      restart.
      >
      I know that the App.Config parameter is read only, but is there anyway
      to override this and tell the Datasource to use the dynamically
      created connection string?
      >
      Any help???
      >
      Thanks,
      Robert
      >

      Comment

      Working...