Hello,
I am working on an ASP.NET / VB page and I created a variable "query":
Sub Page_Load(sende r As Object, e As System.EventArg s)
Dim query as String = String.Empty
...
query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query
End Sub
I need "query" to be global and accessible everywhere.
How can I do this?
Thanks,
Miguel 41 10634
If you want query variable to be accessed in all the pages then declare that
variable in application scope or put it in cache.
--
Saravana http://dotnetjunkies.com/WebLog/saravana/ www.ExtremeExperts.com
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message
news:OP******** ******@TK2MSFTN GP09.phx.gbl... Hello,
I am working on an ASP.NET / VB page and I created a variable "query":
Sub Page_Load(sende r As Object, e As System.EventArg s) Dim query as String = String.Empty ... query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query End Sub
I need "query" to be global and accessible everywhere. How can I do this?
Thanks, Miguel
With a web app, generally your global variables should be stored in the
Application Object or Cache object. This way they are explicity made
accessible to all code in your app.
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message
news:OP******** ******@TK2MSFTN GP09.phx.gbl... Hello,
I am working on an ASP.NET / VB page and I created a variable "query":
Sub Page_Load(sende r As Object, e As System.EventArg s) Dim query as String = String.Empty ... query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query End Sub
I need "query" to be global and accessible everywhere. How can I do this?
Thanks, Miguel
Hello,
Can you tell me how to store the global variables in the Application
Object?
What should the code be and where should I place it?
I am just starting with ASP.NET.
Thanks,
Miguel
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:St***@Orr. net: With a web app, generally your global variables should be stored in the Application Object or Cache object. This way they are explicity made accessible to all code in your app.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message
news:OP******** ******@TK2MSFTN GP09.phx.gbl... Hello,
I am working on an ASP.NET / VB page and I created a variable "query":
Sub Page_Load(sende r As Object, e As System.EventArg s) Dim query as String = String.Empty ... query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query End
Sub
I need "query" to be global and accessible everywhere. How can I do this?
Thanks, Miguel
You could also insert a key in the application's
web.config and read it whenever you need it.
First, include this in your web.config :
<appSettings>
<add key="query1" value="SELECT * FROM dbo.documents WHERE"/>
</appSettings>
Then, retrieve it with this :
Dim query1 As String = System.Configur ation.Configura tionSettings.Ap pSettings("quer y1")
The value for query1 will be available at the Application scope level.
Values read from the web.config file are always of type String.
This method has the advantage that you can have multiple
queries stored in web.config, to be used as needed.
Juan T. Llibre
===========
"Saravana" <sa******@sct.c o.in> wrote in message
news:4m******** *********@news. cpqcorp.net... If you want query variable to be accessed in all the pages then declare that variable in application scope or put it in cache.
-- Saravana http://dotnetjunkies.com/WebLog/saravana/ www.ExtremeExperts.com
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message news:OP******** ******@TK2MSFTN GP09.phx.gbl... Hello,
I am working on an ASP.NET / VB page and I created a variable "query":
Sub Page_Load(sende r As Object, e As System.EventArg s) Dim query as String = String.Empty ... query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query End Sub
I need "query" to be global and accessible everywhere. How can I do this?
Thanks, Miguel
'To store a variable:
Application.Loc k()
Application("My Var")="whatever "
Application.Unl ock()
'to retrieve the variable:
Dim s as String = Application("My Var").ToString( )
--
I hope this helps,
Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Hello,
Can you tell me how to store the global variables in the Application Object? What should the code be and where should I place it?
I am just starting with ASP.NET.
Thanks, Miguel
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message news:St***@Orr. net: With a web app, generally your global variables should be stored in the Application Object or Cache object. This way they are explicity made accessible to all code in your app.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message
news:OP******** ******@TK2MSFTN GP09.phx.gbl... > Hello, > > I am working on an ASP.NET / VB page and I created a variable "query": > > Sub Page_Load(sende r As Object, e As System.EventArg s) > Dim query as String = String.Empty > ... > query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query > End > > Sub > > I need "query" to be global and accessible everywhere. > How can I do this? > > Thanks, > Miguel >
Wouldn't it be better to use Cache?
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:u5******** ******@TK2MSFTN GP10.phx.gbl... 'To store a variable: Application.Loc k() Application("My Var")="whatever " Application.Unl ock()
'to retrieve the variable: Dim s as String = Application("My Var").ToString( )
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Hello,
Can you tell me how to store the global variables in the Application Object? What should the code be and where should I place it?
I am just starting with ASP.NET.
Thanks, Miguel
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message news:St***@Orr. net: With a web app, generally your global variables should be stored in the Application Object or Cache object. This way they are explicity made accessible to all code in your app.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in
message news:OP******** ******@TK2MSFTN GP09.phx.gbl... > Hello, > > I am working on an ASP.NET / VB page and I created a variable
"query": > > Sub Page_Load(sende r As Object, e As System.EventArg s) > Dim query as String = String.Empty > ... > query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query > End > > Sub > > I need "query" to be global and accessible everywhere. > How can I do this? > > Thanks, > Miguel >
Steve,
Doesn't serializing the access to the Application object
using the Lock and UnLock methods mean you have to
accept a considerable performance hit ?
It seems to me that, although using the Application object
gets the job done, it does so in a very inefficient way.
That's why I suggested adding a key in web.config,
and retrieving *that* whenever needed.
Juan T. Llibre
===========
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:u5******** ******@TK2MSFTN GP10.phx.gbl... 'To store a variable: Application.Loc k() Application("My Var")="whatever " Application.Unl ock()
'to retrieve the variable: Dim s as String = Application("My Var").ToString( )
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Hello,
Can you tell me how to store the global variables in the Application Object? What should the code be and where should I place it?
I am just starting with ASP.NET.
Thanks, Miguel
"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message news:St***@Orr. net: With a web app, generally your global variables should be stored in the Application Object or Cache object. This way they are explicity made accessible to all code in your app.
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net
"Miguel Dias Moura" <md*REMOVE*mour a@*NOSPAM*gmail .com> wrote in message
news:OP******** ******@TK2MSFTN GP09.phx.gbl... > Hello, > > I am working on an ASP.NET / VB page and I created a variable "query": > > Sub Page_Load(sende r As Object, e As System.EventArg s) > Dim query as String = String.Empty > ... > query = String.Format(" SELECT * FROM dbo.documents WHERE ") & query > End > > Sub > > I need "query" to be global and accessible everywhere. > How can I do this? > > Thanks, > Miguel >
"Juan T. Llibre [MVP]" <no***********@ nowhere.com> wrote in message
news:uB******** ******@TK2MSFTN GP11.phx.gbl... Steve,
Doesn't serializing the access to the Application object using the Lock and UnLock methods mean you have to accept a considerable performance hit ?
Steve, why do you need to serialize writes? Updates maybe, but why simple
writes?
John Saunders
Searching the underlying data structure to see if and where the key
exists wouldn't be an atomic operation, something could change in
betwen the 'find the entry' and the 'insert' or 'write' operation.
Fortunately, the docs say the Application object is safe for
multi-threaded access. The Lock / Unlock would't be required for a
single write operation. Reflector shows it uses a slightly more
granular reader/writer lock underneath for thread safety:
this._lock.Acqu ireWrite();
try
{
base.BaseSet(na me, value);
}
finally
{
this._lock.Rele aseWrite();
}
--
Scott http://www.OdeToCode.com/blogs/scott/
On Tue, 14 Dec 2004 13:13:43 -0500, "John Saunders" <johnwsaundersi ii
at hotmail.com> wrote: "Juan T. Llibre [MVP]" <no***********@ nowhere.com> wrote in message news:uB******* *******@TK2MSFT NGP11.phx.gbl.. . Steve,
Doesn't serializing the access to the Application object using the Lock and UnLock methods mean you have to accept a considerable performance hit ?
Steve, why do you need to serialize writes? Updates maybe, but why simple writes?
John Saunders This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: NotGiven |
last post by:
I have an file I call using:
require_once()
In this file I have variables I'd like to use in the calling page and
functions called by that page.
How can I do this?
example:
|
by: Andy Fish |
last post by:
Hi,
can anybody put forward a sensible argument javascript's behaviour of
creating a new global variable whenever I assign to a previously undeclared
variable. I can't beleive this is just for the sake of convenience (surely
we learned this much from basic).
here's my proposal: all "global" (document scope) variables must be declared
by...
|
by: rick |
last post by:
Noob problem. I prefer to keep all my scripts in an external '.js' file.
I am currently loading the external '.js' file from the header. Problem is I
would like to declare
a global variable in the external file, but I keep getting an error about
the object does not exist.
Can someone tell me where or how to declare a global variable in an...
|
by: Joe Molloy |
last post by:
Hi,
I'm wondering is there any way I can get a variable's value from within a
class when the variable has been declared outside the class but in the same
script as the class is contained in. For example, say I have the following
script
<?php
constant myvar = "my original string";
|
by: Russ Chinoy |
last post by:
Hi,
This may be a totally newbie question, but I'm stumped.
If I have a function such as:
function DoSomething(strVarName) {
.....
}
| |
by: didier.doussaud |
last post by:
I have a stange side effect in my project :
in my project I need to write "gobal" to use global symbol :
....
import math
....
def f() :
global math # necessary ?????? else next line generate an error
message ?????
|
by: kid_kei |
last post by:
Say there are two classes: System_Controller_Class and UDP_Input_Class.
If I were to declare an instance of class UDP_Input_Class in
System_Controller_Class like so:
extern UDP_Input_Class UDP_Input;
what would be the significance? why not just declare an instance of
the class without the extern? What does adding the extern buy you...
|
by: yinglcs |
last post by:
Hi,
I have the following code:
colorIndex = 0;
def test():
print colorIndex;
This won't work. But it works if i do this:
|
by: istillshine |
last post by:
When I control if I print messages, I usually use a global variable
"int silent". When I set "-silent" flag in my command line
parameters, I set silent = 1 in my main.c.
I have many functions that may print some messages.
foo(...)
{
if (!silent)
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |