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

Simple request.querystring problem

Can someone please tell me why this doesn't work!

Error:
Request is not available in this context

Private rowID As Integer = Request.QueryString(ID)

I need to have the variable rowID accessable by a number of other functions
and subs but when I do the above I get the following error!

However if I do

Private rowID As Integer = "1"

It works fine!

Can someone please help!

Thanks
Nov 19 '05 #1
4 4382
The error is not the assigning, its that you cant access request in that
context.
You might get more help if you tell us where you have that line of code.

/Dan

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:7A**********************************@microsof t.com...
Can someone please tell me why this doesn't work!

Error:
Request is not available in this context

Private rowID As Integer = Request.QueryString(ID)

I need to have the variable rowID accessable by a number of other
functions
and subs but when I do the above I get the following error!

However if I do

Private rowID As Integer = "1"

It works fine!

Can someone please help!

Thanks

Nov 19 '05 #2
Hi,

Thanks for the reply!

The code looks something like this!

Thanks

Private rowID As Integer = Request.QueryString(ID)

Private Function GetDocument() As String
Dim ds As DataSet = GetDataSet(("SELECT * FROM tblPageContent WHERE
pageID=" + rowID.ToString()))
Dim table As DataTable = ds.Tables(0)
Dim row As DataRow = table.Rows(0)
Dim doc As String = row("content").ToString()
Return doc
End Function 'GetDocument

Private Sub UpdateDocument(ByVal doc As String)
Dim strSQL As String = ""
strSQL += "UPDATE tblPageContent SET content='"
strSQL += (doc.Replace(Chr(39), Chr(39) + Chr(39)))
strSQL += "' WHERE pageID=" + rowID.ToString()
RunQuery((strSQL))
End Sub 'UpdateDocument

"Daniel Carlsson" wrote:
The error is not the assigning, its that you cant access request in that
context.
You might get more help if you tell us where you have that line of code.

/Dan

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:7A**********************************@microsof t.com...
Can someone please tell me why this doesn't work!

Error:
Request is not available in this context

Private rowID As Integer = Request.QueryString(ID)

I need to have the variable rowID accessable by a number of other
functions
and subs but when I do the above I get the following error!

However if I do

Private rowID As Integer = "1"

It works fine!

Can someone please help!

Thanks


Nov 19 '05 #3
Oh right, I didnt realize you had written Private (ie that it was a class
field)
If you set the field like you do there its called as if from the
constructor. The constructor will be called before you get any Request (as
far as I know). Move the rowID = Request.QueryString(ID) to Page_Load
instead on your Page object, then you have a valid Request.

If you ever think about doing similar to that with a string variable instead
I strongly suggest replacing ' with \' so you dont open up security holes
(if you had String instead of Integer I could have typed "0'; DROP TABLE
tblPageContent;" in your textbox).

Hope that helps
/Dan

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:54**********************************@microsof t.com...
Hi,

Thanks for the reply!

The code looks something like this!

Thanks

Private rowID As Integer = Request.QueryString(ID)

Private Function GetDocument() As String
Dim ds As DataSet = GetDataSet(("SELECT * FROM tblPageContent WHERE
pageID=" + rowID.ToString()))
Dim table As DataTable = ds.Tables(0)
Dim row As DataRow = table.Rows(0)
Dim doc As String = row("content").ToString()
Return doc
End Function 'GetDocument

Private Sub UpdateDocument(ByVal doc As String)
Dim strSQL As String = ""
strSQL += "UPDATE tblPageContent SET content='"
strSQL += (doc.Replace(Chr(39), Chr(39) + Chr(39)))
strSQL += "' WHERE pageID=" + rowID.ToString()
RunQuery((strSQL))
End Sub 'UpdateDocument

"Daniel Carlsson" wrote:
The error is not the assigning, its that you cant access request in that
context.
You might get more help if you tell us where you have that line of code.

/Dan

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:7A**********************************@microsof t.com...
> Can someone please tell me why this doesn't work!
>
> Error:
> Request is not available in this context
>
> Private rowID As Integer = Request.QueryString(ID)
>
> I need to have the variable rowID accessable by a number of other
> functions
> and subs but when I do the above I get the following error!
>
> However if I do
>
> Private rowID As Integer = "1"
>
> It works fine!
>
> Can someone please help!
>
> Thanks


Nov 19 '05 #4
Thanks!

"Daniel Carlsson" wrote:
Oh right, I didnt realize you had written Private (ie that it was a class
field)
If you set the field like you do there its called as if from the
constructor. The constructor will be called before you get any Request (as
far as I know). Move the rowID = Request.QueryString(ID) to Page_Load
instead on your Page object, then you have a valid Request.

If you ever think about doing similar to that with a string variable instead
I strongly suggest replacing ' with \' so you dont open up security holes
(if you had String instead of Integer I could have typed "0'; DROP TABLE
tblPageContent;" in your textbox).

Hope that helps
/Dan

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:54**********************************@microsof t.com...
Hi,

Thanks for the reply!

The code looks something like this!

Thanks

Private rowID As Integer = Request.QueryString(ID)

Private Function GetDocument() As String
Dim ds As DataSet = GetDataSet(("SELECT * FROM tblPageContent WHERE
pageID=" + rowID.ToString()))
Dim table As DataTable = ds.Tables(0)
Dim row As DataRow = table.Rows(0)
Dim doc As String = row("content").ToString()
Return doc
End Function 'GetDocument

Private Sub UpdateDocument(ByVal doc As String)
Dim strSQL As String = ""
strSQL += "UPDATE tblPageContent SET content='"
strSQL += (doc.Replace(Chr(39), Chr(39) + Chr(39)))
strSQL += "' WHERE pageID=" + rowID.ToString()
RunQuery((strSQL))
End Sub 'UpdateDocument

"Daniel Carlsson" wrote:
The error is not the assigning, its that you cant access request in that
context.
You might get more help if you tell us where you have that line of code.

/Dan

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:7A**********************************@microsof t.com...
> Can someone please tell me why this doesn't work!
>
> Error:
> Request is not available in this context
>
> Private rowID As Integer = Request.QueryString(ID)
>
> I need to have the variable rowID accessable by a number of other
> functions
> and subs but when I do the above I get the following error!
>
> However if I do
>
> Private rowID As Integer = "1"
>
> It works fine!
>
> Can someone please help!
>
> Thanks


Nov 19 '05 #5

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

Similar topics

5
by: John | last post by:
I have the following line in my ASP code. If UCase(Trim(CStr(oRset("Suburb"))))=UCase(Trim(CStr(Request.QueryString("link")))) then etc etc end if
1
by: Danny DiNardo | last post by:
I've encountered many problems upgrading my Win2K Server to Windows 2003 Server, not the least of which involve IIS 6.0 and ASP (classic) support. For example... I'm getting Event ID 2236: The...
2
by: Navanith | last post by:
Hi, I wrote a simple aspx page that dumps query string to the browser. Following is the globalization section in web.config <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
4
by: Steve | last post by:
Hi All, This problem is really annoying me, as I am sure there is a simple solution to it. If I try to read a querystring value in the Page_Load event and that querystring does not exist I...
2
by: mahsa | last post by:
Hi have have some link like thi http://x.com/Shoppingcart.aspx?pn=ps50210&qty_ps50210=1&pn=excel&qty_excel=1&pn=l4504000&qty_l4504000=1&sku=PS50210&cat=laminate&action=updat now I want to request...
1
by: franklinbruce | last post by:
Hi all, I am passing a value from Javascript to a IFrame. when i tired to acces that value like request.querystring("id1") it says "name id1 is not declared" code as follow: ---------------...
0
by: danielle.m.manning | last post by:
I am new to ASP.NET, but have used ASP and VB.NET (Windows Forms) extensively. I am having what I would think should be a simple problem to fix, but is really holding me up. I have a web...
15
by: gjoneshtfc | last post by:
Hello, I have a simple problem that I just cannot get my head around! I currently have the following line in my ASP recordset: Recordset1.Source = "SELECT * FROM MainTable ORDER BY Price ASC"...
4
by: .nLL | last post by:
Hi, im am a classic asp developer and started to learn asp.net but got stuck with a simple problem even before i step in to further. to learn i have started from a simple project (a login system...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.