473,396 Members | 2,059 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,396 software developers and data experts.

Share Variables Among the classes

Hi, sorry for the pretty question.

i want to change this Connection String at RunTime

namespace NeoBiblos.BiblosDataSetTableAdapters
{
....

public partial class ArgomentTableAdapter : ..... {
.....
private void InitConnection() {
this._connection.ConnectioString = "MYPATH";
}
.....
}
.....
}

the user uses a openFileDialog in a Form (in the NeoBiblos namespace)
to choose the path, but how can i use the string choosen by the user in
the other namespace ???
I would create something like a shared variable MYPATH that the user
sets, and the other class gets, but i don't know how (where).
and i don't know where the InitConnection method is called in the
application so i can't override the method.

May 5 '06 #1
1 2183
Just create a utility class that is referenced by the others and each has a
using directive for it. The class would have a public static string field
called "connectionString".
When your user selects the file, you can get the string and populate this
variable.
static has the effect of being a global variable that can be seen by all
classes.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Mario-ITA" wrote:
Hi, sorry for the pretty question.

i want to change this Connection String at RunTime

namespace NeoBiblos.BiblosDataSetTableAdapters
{
....

public partial class ArgomentTableAdapter : ..... {
.....
private void InitConnection() {
this._connection.ConnectioString = "MYPATH";
}
.....
}
.....
}

the user uses a openFileDialog in a Form (in the NeoBiblos namespace)
to choose the path, but how can i use the string choosen by the user in
the other namespace ???
I would create something like a shared variable MYPATH that the user
sets, and the other class gets, but i don't know how (where).
and i don't know where the InitConnection method is called in the
application so i can't override the method.

May 6 '06 #2

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

Similar topics

3
by: Anthony Davis | last post by:
Hello all, Can someone please tell me if there is a way to declare variables within a class that can be shared among each new object created from this class? For instance I have the following: ...
6
by: Tony Fonager | last post by:
I am currently developing a statistics system in ASP.NET, and need to share information about the customers websites, in this application. (I have simplified my code, to make my project easier to...
8
by: Tony Fonager | last post by:
I am currently developing a statistics system in ASP.NET, and need to share information about the customers websites, in this application. (I have simplified my code, to make my project easier to...
3
by: Garth17 | last post by:
I'm trying to figure out a solution for sharing common properties and methods in all me .aspx and .ascx pages. In classic ASP I would use include directives. So far I have made 2 base classes...
6
by: Gregory Gadow | last post by:
In a VB.Net 2.0 project, I have a WizardClass that contains a List (of RuleClass). Each rule needs access to variables within it's parent wizard, so the constructor for RuleClass is New (ByVal...
3
by: Bob Peek | last post by:
I would like to share code between several web sites that exist as virtual directories under a single site. It appears that I have to create an app_code directory under each virtual root in order...
5
by: Scott Starker | last post by:
Is there anyway to do this? Every time any button is click inside class Form1, MyButtomArray.CharArray (MyButtomArray is a class) gets set (or reset) (bool). Once this is done the class TEC gets...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
6
by: Immortal Nephi | last post by:
First class is the base class. It has two data: m_Base1 and m_Base2. Second class and third class are derived classes and they are derived from first class. m_Base1 and m_Base2 are inherited into...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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,...
0
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...

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.