global variables in .NET: how to store a connection string and have it available throughout..

C

chris

There's a simple answer I'm sure, but it's eluding me. If I want to declare
a variable and then initialize it in module A, then have it's initialized
value available in module B without passing it as an argument, how to do?

Thanks,
Chris
 
M

Miha Markic

Hi chris,

VB.NET:
Module Module2

Public AValue As String = "Tubo"

End Module

Use: Dim s as string = Module2.AValue



C#:

public class Tubo

{

public static string AValue = "Tubo";

}

Use: string s = Tubo.AValue;
 
T

trainspotter747

I tried this solution in storing the user's login name. The first .aspx file shows the initial value of the login name variable declared inside the module and prompts the user to enter his own login name . how come when I run the application in VS.NET again, the same login name last inputted shows up, it's like the module doesn't reset it's own value.

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
M

Miha Markic

Hi Troy,

You should say that you are on the asp.net :)
Store it in the either Session collection (Session["key"] = value) or
Application collection (Application["key"] = value) .

--
Miha Markic - DXSquad/RightHand .NET consulting & software development
miha at rthand com

Developer Express newsgroups are for peer-to-peer support.
For direct support from Developer Express, write to (e-mail address removed)
Bug reports should be directed to: (e-mail address removed)
Due to newsgroup guidelines, DX-Squad will not answer anonymous postings.


Troy trainspotter Montero said:
I tried this solution in storing the user's login name. The first .aspx
file shows the initial value of the login name variable declared inside the
module and prompts the user to enter his own login name . how come when I
run the application in VS.NET again, the same login name last inputted shows
up, it's like the module doesn't reset it's own value.
**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top