469,930 Members | 1,722 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,930 developers. It's quick & easy.

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/ =-

Apr 29 '06 #1
2 1841
Malice,

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

Do you not see that?

Cor

"malice" <ma*@u.com> schreef in bericht
news:44*********************@auth.newsreader.octan ews.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/ =-

Apr 29 '06 #2
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" connectionsetting, while
using CreateDatabase(name) will read the specified connection setting.

If using the Enterprise Library is a "Requirement", 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 "Requirement", 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" <ma*@u.com> wrote in message
news:44*********************@auth.newsreader.octan ews.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/ =-
|
Apr 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Mihai Velicu | last post: by
7 posts views Thread by Peter Bradley | last post: by
2 posts views Thread by =?Utf-8?B?SGVsZW4gVHJpbQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.