Ent Library. Substitute data from app.config?

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

    #1

    Ent Library. Substitute data from app.config?

    I have been searching the internet for 12+ hours on how to do this. At this point I'm about to give up. I am using VB .Net 2.0 with the enterprise library jan 2006 release. This is my first time using it and I'm a novice to .Net. I am using the data access quickstart solution and I just started adding my own forms and stuff to it. I got my sql query to work and populate a dataview on my new form with just a few lines of code. Here is my problem :
    I work in an environment where we have 2000+ MS SQL servers. My app will use a text box to get the name of the server you wish to connect to and retrieve data. The ent lib seems to have the server name hard coded in the app.config file. When I use my createdatabase method how do I substitute a different server name from the one in the app.config? I need this to be as simple as possible becase I am a novice and might not be able to implement something that is too complex.


    --------------= Posted using GrabIt =----------------
    ------= Binary Usenet downloading made easy =---------
    -= Get GrabIt for free from http://www.shemes.com/ =-

  • Cor Ligthert [MVP]

    #2
    Re: Ent Library. Substitute data from app.config?

    Malice,

    If there is one type of file not hardcoded than it are config files.

    Do you not see that?

    Cor

    "malice" <mad@u.com> schreef in bericht
    news:44538c87$0 $160$892e0abb@a uth.newsreader. octanews.com...[color=blue]
    >I have been searching the internet for 12+ hours on how to do this. At this
    >point I'm about to give up. I am using VB .Net 2.0 with the enterprise
    >library jan 2006 release. This is my first time using it and I'm a novice
    >to .Net. I am using the data access quickstart solution and I just started
    >adding my own forms and stuff to it. I got my sql query to work and
    >populate a dataview on my new form with just a few lines of code. Here is
    >my problem :
    > I work in an environment where we have 2000+ MS SQL servers. My app will
    > use a text box to get the name of the server you wish to connect to and
    > retrieve data. The ent lib seems to have the server name hard coded in the
    > app.config file. When I use my createdatabase method how do I substitute a
    > different server name from the one in the app.config? I need this to be as
    > simple as possible becase I am a novice and might not be able to implement
    > something that is too complex.
    >
    >
    > --------------= Posted using GrabIt =----------------
    > ------= Binary Usenet downloading made easy =---------
    > -= Get GrabIt for free from http://www.shemes.com/ =-
    >[/color]


    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: Ent Library. Substitute data from app.config?

      Malice,
      The CreateDatabase method & the Enterprise Library assume that you have
      *all* the servers that you can connect to listed in the app.config.

      Using CreateDatabase( ) will read the "default" connectionsetti ng, while
      using CreateDatabase( name) will read the specified connection setting.

      If using the Enterprise Library is a "Requiremen t", then you have 2 options:
      1) list all 2000+ MS SQL servers in the connection setting section of the
      app config. I would recommend you use the configSource attribute in your
      app.config.
      2) Modify CreateDatabase to accept the SQL server name and/or the connection
      string.

      I would probably opt for the first over the second, as it allows greater
      control over the connection string itself, the user only needs to know the
      "key" to the connection string, which may or may not be the server name
      itself. Of course the first entails a lot of entries in the app.config,
      hence the suggestion of the configSource attribute. The second may be a
      maintenance issue as newer versions of the Enterprise Library are
      released...

      For information on using configSource see "Using .NET's configSource
      attribute" at
      http://blogs.msdn.com/tomholl/archiv...nalconfig.aspx

      If using the Enterprise Library is not a "Requiremen t", then you have 2
      options:
      1) list all 2000+ MS SQL servers in the connection setting section of the
      app config. I would recommend you use the configSource attribute in your
      app.config.
      2) Build the required connection string then passing this to a SqlConnection
      object.


      Again the first allows greater control over the connection string itself,
      while the second would probably more code yet smaller app.config file...

      --
      Hope this helps
      Jay B. Harlow [MVP - Outlook]
      ..NET Application Architect, Enthusiast, & Evangelist
      T.S. Bradley - http://www.tsbradley.net


      "malice" <mad@u.com> wrote in message
      news:44538c87$0 $160$892e0abb@a uth.newsreader. octanews.com...
      |I have been searching the internet for 12+ hours on how to do this. At this
      point I'm about to give up. I am using VB .Net 2.0 with the enterprise
      library jan 2006 release. This is my first time using it and I'm a novice to
      ..Net. I am using the data access quickstart solution and I just started
      adding my own forms and stuff to it. I got my sql query to work and populate
      a dataview on my new form with just a few lines of code. Here is my problem
      :
      | I work in an environment where we have 2000+ MS SQL servers. My app will
      use a text box to get the name of the server you wish to connect to and
      retrieve data. The ent lib seems to have the server name hard coded in the
      app.config file. When I use my createdatabase method how do I substitute a
      different server name from the one in the app.config? I need this to be as
      simple as possible becase I am a novice and might not be able to implement
      something that is too complex.
      |
      |
      | --------------= Posted using GrabIt =----------------
      | ------= Binary Usenet downloading made easy =---------
      | -= Get GrabIt for free from http://www.shemes.com/ =-
      |


      Comment

      Working...