Need more Request.QueryString and Request.Form help 
Author Message
 Need more Request.QueryString and Request.Form help

Hi Again,

OK, I've taken a lot away from this group and have tried very hard to apply
and understand it all, but I'm afraid that I'm still having problems. Some
of you here have referred to coding using the Request.QueryString as a bad
idea because each time you call it you are hitting *i don't know what* and
it's slow, so you should instead use a variable for referencing the
Request.QueryString. Please correct me if I'm wrong, but aren't you hitting
it each time you assign the Request.QueryString("whatever") to a variable?
So if I have 100 items in Request.QueryString and I assign each one to a
variable so that I can check if it's set, aren't I doing the same as if I
just said Request.QueryString("whatever") <> ""? I'm having a hard time
understanding the advantage. :( And I feel stupid...

So I figured that it would just be easier to make an array and assign the
Request.QueryString to it then loop through my new array and check for key
value pairs, but I can't get it to work with any of the examples I've found
using key and item or for/next or for each, etc.. I get errors ranging from
"type mismatch" to "out of bounds" and other things I don't understand. In
other languages you could use an array reference or use pointers, but I
can't figure out if VBScript has that ability or if I just don't understand
how to create them.

So at this point, either I'm doing "bad/weak" coding and using the
Request.QueryString or Request.Form everywhere (in other languages it's just
a hash available so there is no performance hit) or I'm manually setting
each item in both to a distinct variable. The problem with this is that soon
I need to create a page with dynamic info from databases and need the
databases to be changeable (i.e. if the person maintaining the page wants to
add fields I need to be able to dynamically display them and at that point I
won't be able to hard code the field names.)

So I guess what I'm looking for is something similar to this PHP code:

foreach ( $HTTP_QUERY_STRING as $key => $value){

    $myNewHash[$key] = $value;

Quote:
}

OR (by reference)

$myNewHash = &$HTTP_QUERY_STRING;

OR ....help?

Thanks again everybody for being so helpful with a VBScript newbie. I really
appreciate it and hope that I can catch on soon. I hate feeling this dumb.
:(

Stephanie



Mon, 13 Sep 2004 15:38:49 GMT  
 Need more Request.QueryString and Request.Form help
  Set myNewHash = Response.Querystring

Then you can refer to querystring variables with myNewHash("myVariable") instead
of Response.Querystring("myVariable"). Every dot you remove from a reference
decreases the performance hit. You just have to decide if the performance hit of
setting up the new reference is compensated for by the reduced hit of removing
the dot in later references. :-)

--
Knowing others is intelligence; knowing yourself is true wisdom. Mastering
others is strength, mastering yourself is true power. -Lao-Tzu

=-=-=
Steve
-=-=-


Quote:
> Hi Again,

> OK, I've taken a lot away from this group and have tried very hard to apply
> and understand it all, but I'm afraid that I'm still having problems. Some
> of you here have referred to coding using the Request.QueryString as a bad
> idea because each time you call it you are hitting *i don't know what* and
> it's slow, so you should instead use a variable for referencing the
> Request.QueryString. Please correct me if I'm wrong, but aren't you hitting
> it each time you assign the Request.QueryString("whatever") to a variable?
> So if I have 100 items in Request.QueryString and I assign each one to a
> variable so that I can check if it's set, aren't I doing the same as if I
> just said Request.QueryString("whatever") <> ""? I'm having a hard time
> understanding the advantage. :( And I feel stupid...

> So I figured that it would just be easier to make an array and assign the
> Request.QueryString to it then loop through my new array and check for key
> value pairs, but I can't get it to work with any of the examples I've found
> using key and item or for/next or for each, etc.. I get errors ranging from
> "type mismatch" to "out of bounds" and other things I don't understand. In
> other languages you could use an array reference or use pointers, but I
> can't figure out if VBScript has that ability or if I just don't understand
> how to create them.

> So at this point, either I'm doing "bad/weak" coding and using the
> Request.QueryString or Request.Form everywhere (in other languages it's just
> a hash available so there is no performance hit) or I'm manually setting
> each item in both to a distinct variable. The problem with this is that soon
> I need to create a page with dynamic info from databases and need the
> databases to be changeable (i.e. if the person maintaining the page wants to
> add fields I need to be able to dynamically display them and at that point I
> won't be able to hard code the field names.)

> So I guess what I'm looking for is something similar to this PHP code:

> foreach ( $HTTP_QUERY_STRING as $key => $value){

>     $myNewHash[$key] = $value;

> }

> OR (by reference)

> $myNewHash = &$HTTP_QUERY_STRING;

> OR ....help?

> Thanks again everybody for being so helpful with a VBScript newbie. I really
> appreciate it and hope that I can catch on soon. I hate feeling this dumb.
> :(

> Stephanie



Mon, 13 Sep 2004 21:24:45 GMT  
 Need more Request.QueryString and Request.Form help
Stephanie,

Don't sweat it too much ... you just have to try and ensure that every
project, every piece of code, is better and cleaner than the one before. You
don't have to get it 'right' now, because in 3 months time you'll still be
writing better code ... so just concentrate on being aware of the fact that
there are better ways to almost everything (even when you think otherwise),
and just constantly striving to make yourself a better programmer.

What the guys are referring to is the fact that when you have the codee do
something like this: "Request.QueryString("Whatever")" the .asp engine
scuttles off to the Request Object, then the QueryString of the Request
object and then looks for your variable and returns the value.

If you used just Request("whatever") - which is valid - the .asp engine
would look in the request object and then pick either FORM or QUERYSTRING
and look for "whatever", but now it's checking both ... which is obviously
less refined. Hence a slight performance hit.

Now, if you type 100 request.queryString("variable") commands, the asp
engine is looking in the request object, then the querystring object 100
times.

If you tell ASP that you are always looking in the request object initially,
it can miss out this stage - thus halving the work done. Does this make
sense?

So, by assigning a variable to Request.QueryQueryString: myVar =
Request.QueryString, you are telling .asp to just work in the querystring
object, thus reducing the number of steps that it has to make.

Is it worth it for 3 or 4 requests? probably not. Is is worth it for 100 of
them? Oh yes, yes it is. Do you see why now?

This is one reason why the WITH command is used, because it tells .asp/vbs
that the nested block is working with the same object and position within
the object, thus reducing the need for vbs to figure it out for itself.

I've over simplified somewhat and someone out there is going to jump on my
use of the phrase 'asp engine', but you get the idea ....


Quote:
> Hi Again,

> OK, I've taken a lot away from this group and have tried very hard to
apply
> and understand it all, but I'm afraid that I'm still having problems. Some
> of you here have referred to coding using the Request.QueryString as a bad
> idea because each time you call it you are hitting *i don't know what* and
> it's slow, so you should instead use a variable for referencing the
> Request.QueryString. Please correct me if I'm wrong, but aren't you
hitting
> it each time you assign the Request.QueryString("whatever") to a variable?
> So if I have 100 items in Request.QueryString and I assign each one to a
> variable so that I can check if it's set, aren't I doing the same as if I
> just said Request.QueryString("whatever") <> ""? I'm having a hard time
> understanding the advantage. :( And I feel stupid...

> So I figured that it would just be easier to make an array and assign the
> Request.QueryString to it then loop through my new array and check for key
> value pairs, but I can't get it to work with any of the examples I've
found
> using key and item or for/next or for each, etc.. I get errors ranging
from
> "type mismatch" to "out of bounds" and other things I don't understand. In
> other languages you could use an array reference or use pointers, but I
> can't figure out if VBScript has that ability or if I just don't
understand
> how to create them.

> So at this point, either I'm doing "bad/weak" coding and using the
> Request.QueryString or Request.Form everywhere (in other languages it's
just
> a hash available so there is no performance hit) or I'm manually setting
> each item in both to a distinct variable. The problem with this is that
soon
> I need to create a page with dynamic info from databases and need the
> databases to be changeable (i.e. if the person maintaining the page wants
to
> add fields I need to be able to dynamically display them and at that point
I
> won't be able to hard code the field names.)

> So I guess what I'm looking for is something similar to this PHP code:

> foreach ( $HTTP_QUERY_STRING as $key => $value){

>     $myNewHash[$key] = $value;

> }

> OR (by reference)

> $myNewHash = &$HTTP_QUERY_STRING;

> OR ....help?

> Thanks again everybody for being so helpful with a VBScript newbie. I
really
> appreciate it and hope that I can catch on soon. I hate feeling this dumb.
> :(

> Stephanie



Mon, 13 Sep 2004 21:42:30 GMT  
 Need more Request.QueryString and Request.Form help


Fri, 19 Jun 1992 00:00:00 GMT  
 Need more Request.QueryString and Request.Form help
Steve and Jennifer,

I just wanted to say thanks again for helping me out. You all have been so
very helpful and I really appreciate it. Knowing WHY certain code works the
way it does helps so much more than just knowing how to do it. While the
latter get's the job done, the former helps set the foundation for using the
language to it's fullest and making the right descisions and I think that
makes the difference between a coder and a programmer. :) There is so much
to learn, but with people like you around, it makes learning this new beast
so much easier. You guys are the best!

Thanks again,
Stephanie



Fri, 17 Sep 2004 03:18:53 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Can I Request.form and Request.querystring?

2. Request.Querystring/Form

3. need help converting request.form collection to an array for sorting - newbie

4. Request.QueryString help

5. reading REQUEST.FORM and REQUEST.SERVERVARIABLES from a DLL

6. How to use VBA to send Request QueryString to an ASP page

7. Serializing Request.Querystring

8. NameValueCollection, Request.QueryString, WebForm usage

9. For each sKey in Request.QueryString returns Error 451

10. Request.Querystring

11. Problems with listbox and asp and request.querystring.

12. Request.QueryString

 

 
Powered by phpBB® Forum Software