473,705 Members | 3,166 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VS2005 - ConnectionStrin g - 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.Diagnost ics.DebuggerNon UserCodeAttribu te()]
private void InitConnection( ) {
this._connectio n = new
System.Data.Sql Client.SqlConne ction();
this._connectio n.ConnectionStr ing =
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring;
}

Therefore it seems that if there is a way to override the value of:
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring
at the start of the program then my problem would be solved.

Unfortunately
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring
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 7975

| [System.Diagnost ics.DebuggerNon UserCodeAttribu te()]
| private void InitConnection( ) {
| this._connectio n = new
| System.Data.Sql Client.SqlConne ction();
| this._connectio n.ConnectionStr ing =
|
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring;
| }
|
| Therefore it seems that if there is a way to override the value of:
|
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring
| at the start of the program then my problem would be solved.
|
| Unfortunately
|
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring
| is read-only.
|
| Any solutions to these guys?

Just do something like:

this._connectio n.ConnectionStr ing = "myconnectionSt ring";
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.GetF olderPath(Envir onment.SpecialF older.CommonApp licationData) <-
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.fr wrote 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.Diagnost ics.DebuggerNon UserCodeAttribu te()]
private void InitConnection( ) {
this._connectio n = new System.Data.Sql Client.SqlConne ction();
this._connectio n.ConnectionStr ing =
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring;
}

Therefore it seems that if there is a way to override the value of:
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring
at the start of the program then my problem would be solved.

Unfortunately
global::Forecas tSkillVerificat ion.Properties. Settings.Defaul t.Speed_62_MM_G OODConnectionSt ring
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._connectio n.ConnectionStr ing = "myconnectionSt ring";
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
1794
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 during development environment using Visual Basic 6 (For example, an error pops out saying License is not found - I am using 3rd party components.)?
0
1268
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: The problem is that my license provider never gets called at designtime. To prove this, I've put this code into the implementation
9
2700
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 2000. In my case the server I couldn't reach was across a vpn connection, behind ISA server 2000, (which had port 1433 open). The answer was in this post:...
16
1734
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 development of a VC++ component. Does Microsoft still offer any free bug reporting cases for VS2005, as they did two for VS2003 so that I can talk with a technical representative directly to try to find a workaround for the compiler bug ? While...
7
2220
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
1035
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 this works runtime when i change the value designtime. But it is a hazzle to run the page to see how it will look like. Anyone ?
4
12495
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 installed directory of user choice. The DataSet is created using wizard at design-time. Thanks for your help.
2
1700
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 is? This is my code:
1
2059
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 DesignTime master is a single level master page incorporating both the content of the MasterPage and the SubMaster, so that I can get around the fact that you can't see content pages in Design mode if they use nested masters.
0
8690
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6606
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5933
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2491
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2083
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.