473,387 Members | 1,891 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,387 software developers and data experts.

VS2005 - ConnectionString - DesignTime - Change at Runtime

Hi,

We have an app that is made of many exes (WinForms and Win32 app).

All those exes share and read their DB connection string from the
registry. This guarantees that all the exes use the same DB.

With .Net the connection string is in the app.config file as soon as
you use the design time functionality to bind data to grids as an
example. So when you have 20 exes you have 20 app.config and the
possibility to use 20 different connection string which is really bad!

So I want to use that shared and common DB connection string. The
problem is that it seems we either have the choice of writing all the
code manually in which case we can control the connection string or
using the design time functions of VS but then we lose control of the
connection string which goes into the app.config file.

The question is how can you still use the VS.Net design time function
but make sure that you can when the app start specify the connection
string you want and not the one in the app.config?

I can see that in the data adapters the auto-generated code specifies:

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
private void InitConnection() {
this._connection = new
System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString =
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString;
}

Therefore it seems that if there is a way to override the value of:
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString
at the start of the program then my problem would be solved.

Unfortunately
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString
is read-only.

Any solutions to these guys?

thanks,
M

--
Michael
----
http://michael.moreno.free.fr/
http://port.cogolin.free.fr/
Mar 14 '07 #1
3 7958

| [System.Diagnostics.DebuggerNonUserCodeAttribute()]
| private void InitConnection() {
| this._connection = new
| System.Data.SqlClient.SqlConnection();
| this._connection.ConnectionString =
|
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString;
| }
|
| Therefore it seems that if there is a way to override the value of:
|
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString
| at the start of the program then my problem would be solved.
|
| Unfortunately
|
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString
| is read-only.
|
| Any solutions to these guys?

Just do something like:

this._connection.ConnectionString = "myconnectionString";
Mar 14 '07 #2
VJ
Simple solution would be to put the connect information in a common location
like All User's Application specific datapath, and make all applications
look for it there.

This is available from
Enviroment.GetFolderPath(Environment.SpecialFolder .CommonApplicationData) <-
lets you see the above.. works from .NET apps..., and sure there is a way to
read in Win32apps, I am just not sure of syntax

VJ

"Michael Moreno" <My*******************@free.frwrote in message
news:mn***********************@free.fr...
Hi,

We have an app that is made of many exes (WinForms and Win32 app).

All those exes share and read their DB connection string from the
registry. This guarantees that all the exes use the same DB.

With .Net the connection string is in the app.config file as soon as you
use the design time functionality to bind data to grids as an example. So
when you have 20 exes you have 20 app.config and the possibility to use 20
different connection string which is really bad!

So I want to use that shared and common DB connection string. The problem
is that it seems we either have the choice of writing all the code
manually in which case we can control the connection string or using the
design time functions of VS but then we lose control of the connection
string which goes into the app.config file.

The question is how can you still use the VS.Net design time function but
make sure that you can when the app start specify the connection string
you want and not the one in the app.config?

I can see that in the data adapters the auto-generated code specifies:

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
private void InitConnection() {
this._connection = new System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString =
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString;
}

Therefore it seems that if there is a way to override the value of:
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString
at the start of the program then my problem would be solved.

Unfortunately
global::ForecastSkillVerification.Properties.Setti ngs.Default.Speed_62_MM_GOODConnectionString
is read-only.

Any solutions to these guys?

thanks,
M

--
Michael
----
http://michael.moreno.free.fr/
http://port.cogolin.free.fr/


Mar 14 '07 #3
Just do something like:
>
this._connection.ConnectionString = "myconnectionString";
Yes thanks.
But this code has been automatically generated hence if I modify it VS
may change it, may it not ?

--
Michael
----
http://michael.moreno.free.fr/
http://port.cogolin.free.fr/
Mar 15 '07 #4

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

Similar topics

0
by: Rahail | last post by:
Hello, I have a question, can someone help me please? What are the differences between a runtime and a designtime component? Is runtime component only good for running with the .exe and not...
0
by: stew_mclean | last post by:
Hi, I've developed a class that derives from component (rather than a control), and am trying to license it at design time. I've set the license attributes etc. to my custom license provider: ...
9
by: RvGrah | last post by:
After much hair-pulling, I've finally found the answer to a problem that many are fighting with, difficulty connecting from Sql 2005 Server Management or VS2005 to a remote Sql Server running Sql...
16
by: Edward Diener | last post by:
After spending more than a day reducing a complicated compiler bug to a simple case I reported it to the MSDN Product Feedback Center as a bug just now. However this bug is completely stymying my...
7
by: Varangian | last post by:
Hello is creating controls at runtime the same as designtime ? will a page be faster if controls are created at designtime rather than at runtime ? If so why ? thanks :)
0
by: Dst | last post by:
How can i resize my usercontrol in design mode ? Seems like when the usercontrol is added to a page the size is fixed. It does not have any resize grips. I added a width / height property and...
4
by: wilson | last post by:
Hi. I'm new in VB.NET. I would like to ask a question. How to change ConnectionString for DataSet at runtime? Because I want to change the dBase data file directory according to the program...
2
by: rotsj | last post by:
Hello, I would like to make my own dropdownlist and add a collection as a generic List. When I enter items @ designtime, @ runtime they are gone. Can anyone tell me please what the problem...
1
by: daveh551 | last post by:
Okay, another problem I'm having with nested master pages on VS 2005. I've got a MasterPage,master, as SubMaster.master, and a DesignTime.master, and a content page, default.aspx. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.