473,386 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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.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

Jul 25 '07 #1
2 4136
>
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.

Jul 25 '07 #2
Hi,

is this what you are looking for?

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

Regards,

Martin
"RB0135" <ro****@joshie.com.auwrote in message
news:11*********************@z28g2000prd.googlegro ups.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.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

Jul 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pankaj Banga | last post by:
When I create a DataSet using Data Source Configuration wizard the connection string gets added to application configuration, public read only property gets created in settings class and...
2
by: MattB | last post by:
I'm trying to implement an example I found for displaying images stored in a SQL database. The example code looks like this (in page_load): Dim connstr As String = "Integrated...
32
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's...
4
by: phil | last post by:
Hi, With the code below, i get the error: ExecuteReader: Connection property has not been initialized. Description: An unhandled exception occurred during the execution of the current web...
0
by: saraDotNet | last post by:
hi everybody , I'm a beginner student in vb.net,and I'm working on a very small project as a homework,and I've some questions which I ought to search for their solutions via any source . My...
1
by: sandeepjakhotya | last post by:
Hello All Enyone knows how to change DB Location for the Crystal Report in VB 6. I have created a application in vb 6 and report in crystal report 9.0 The report created is then added to vb...
2
by: frankkirchner | last post by:
I'm new to both VS2005 and C# Web Forms (Though I have tons of experience with VB.Net and VS2003). Creating a Data Source visually in VS2005 is easy as pie - I love it, but how do you or would...
1
by: Corey B | last post by:
I have a page with a DetailsView control and a SQLDataSource control. The SQLDataSource control is connected to an Access database. Everything works fine. Now I want to change the back end...
2
by: Orit | last post by:
Hello . Please find below my questions - I hope some of the ASP.NET experts of this forum will answer to those beginner's questions : My Web site should be able to work with either SQL Server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.