473,657 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Global Variable for URL param recommendation

Rob
Please recommend best practice for adding a global
variable to an ASP.net class that will take on a
Request.Params( "") value from the URL calling the aspx
page to be used throughout in stored procedure calls as a
parameter in datagrids.

Currently, the best I came up with was to add code around
the Web Form Designer code of the Select statement that
defines the variable and sends it as a Parameter to the
stored procedure. However, Visual studio keeps
overwriting this code everytime I use the GUI tools on the
data objects. Using variable in Select Stored Procedure
paramater call in the Value area.

Is there a better/easier way to send the variable in the
GUI "control source" or value for the data adapter select
statement sp call?

Thank you,

Rob

----
'
'SqlSelectComma nd1
'
'RW - Attempt to globally define EmployeeID from
URL paramater for stored procedure
If Not (Request.Params ("EmployeeID ") Is Nothing)
Then
EmployeeID = Int32.Parse(Req uest.Params
("EmployeeID "))
Else
EmployeeID = "302"
End If
'/RW
Me.SqlSelectCom mand1.CommandTe xt
= "[spGetEmpAttach]"
Me.SqlSelectCom mand1.CommandTy pe =
System.Data.Com mandType.Stored Procedure
Me.SqlSelectCom mand1.Connectio n = Me.SqlConnectio n1
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@RETURN_V ALUE",
System.Data.Sql DbType.Int, 4,
System.Data.Par ameterDirection .ReturnValue, False, CType
(0, Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, Nothing))
'RW
Me.SqlSelectCom mand1.Parameter s.Add(New
System.Data.Sql Client.SqlParam eter("@Employee ID",
System.Data.Sql DbType.Int, 4,
System.Data.Par ameterDirection .Input, False, CType(0,
Byte), CType(0, Byte), "",
System.Data.Dat aRowVersion.Cur rent, EmployeeID))
'/RW
Jul 19 '05 #1
1 1931
Hi Rob,

I think you could store the variable in a session or application state. So
you could get it throughout the web application.

For an example:
Session["EmployeeID "] = EmployeeID;
Application["EmployeeID "] = EmployeeID;

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
Jul 19 '05 #2

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

Similar topics

6
4748
by: Loopy | last post by:
I'm learning XML and XSL at the moment, but I still can't get my head around the concept of non-updatable variables. I know we can use recursion to cycle through a data structure and get the sum (say) of a list of numbers, or a concatination of a set of strings (again, example), but if I wanted to, for example, keep that value available for another template later on to use, I can't see how I could do that. Let me give a better example. I...
0
1321
by: Eshrath Khan | last post by:
Hi all, I have a .Net program which access transforms a XML using an XSL stylesheet. The .net program calls Stylesheet main.xsl file. The main.xls contains only <xsl:include> elements to include other XSL files. like
1
1996
by: Eshrath Khan | last post by:
Hi all, I have a .Net program which access transforms a XML using an XSL stylesheet. The .net program calls Stylesheet main.xsl file. The main.xls contains only <xsl:include> elements to include other XSL files. like
5
2045
by: sworna vidhya | last post by:
Hai, When viewing threads of comp.lang.c, I came across with 'static const char * const resultFileName = "param.txt";' . Here in this thread, 'static const char * const resultFileName = "param.txt";' is declared globally. a) What is the use of declaring a global variable static? b) Why in this thread they had use "const" the two times? c) When mentionting as const, the variable we declared remains
1
3676
by: Rob Wire | last post by:
Please let me know the preferred way to do the following. Accept a Variable in the calling page's URL of an ID. Set that variable to be global scope of the class so that it can be used throughout the functions from Page Load. Would like to send the ID variable as a SQL parameter to stored procedures for Select, Update, and Insert. What I have done so far to get around it is declare it in the SQL Select statements of the Web form code,...
2
327
by: Rob | last post by:
Please recommend best practice for adding a global variable to an ASP.net class that will take on a Request.Params("") value from the URL calling the aspx page to be used throughout in stored procedure calls as a parameter in datagrids. Currently, the best I came up with was to add code around the Web Form Designer code of the Select statement that defines the variable and sends it as a Parameter to the stored procedure. However,...
12
2216
by: a | last post by:
def fn(): for i in range(l) global count count= .... how do i declare count to be global if it is an array subsequently i should access or define count as an array error:
20
12733
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The AutoExec macro calls a function "InitApplication" which, in turn, calls a function to set the value of a global string variable
18
2058
by: Bruce | last post by:
When I do this: <input id="someName" type="text"> <script type="text/javascript"> alert(someName.nodeName); </script> Both IE6 and Firefox alert("INPUT"). Why isn't "someName" undefined?
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
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,...
0
8844
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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
8621
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
6177
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
5643
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();...
1
2743
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

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.