Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

Programmatically changing a Data Source's connection property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RB0135 - 25 Jul 2007 03:39 GMT
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.MySettings.xxxConnectionString 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 - 25 Jul 2007 05:47 GMT
> 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.
Martin - 25 Jul 2007 17:58 GMT
Hi,

is this what you are looking for?

http://www.codeproject.com/useritems/PersistConnectionStrings.asp

Regards,

Martin

> Hi,
>
[quoted text clipped - 29 lines]
> Thanks,
> Robert

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.