473,320 Members | 1,957 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.

how to know a Request.Param value is numeric type or not?

How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Params[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type but
how?

Thanks in advance

E.T.
Nov 16 '05 #1
3 3646
try
{
int id = int.Parse(Request.Params[0]);
// continue with your sql processing
}
catch
{
// show an error message
}

-Jason

2003et wrote:
How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Params[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type but
how?

Thanks in advance

E.T.

Nov 16 '05 #2
oh right...

Thank you

"Jason DeFontes" <ja***@defontes.com> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl...
try
{
int id = int.Parse(Request.Params[0]);
// continue with your sql processing
}
catch
{
// show an error message
}

-Jason

2003et wrote:
How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Params[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type but how?

Thanks in advance

E.T.

Nov 16 '05 #3
And if a user enters:
www.domain.com/myfile.aspx?1;DROP DATABASE master

the page will really fail. ;)
"SELECT name FROM people WHERE id="+Request.Params[0];

2003et wrote:
oh right...

Thank you

"Jason DeFontes" <ja***@defontes.com> wrote in message
news:uo**************@TK2MSFTNGP12.phx.gbl...
try
{
int id = int.Parse(Request.Params[0]);
// continue with your sql processing
}
catch
{
// show an error message
}

-Jason

2003et wrote:
How can I understand a Request.Params object's type?

I need this:
User enters www.domain.com/myfile.aspx?6
then myfile.aspx.cs use
"SELECT name FROM people WHERE id="+Request.Params[0];

so if the user enters the parameter as string instead of integer:
www.domain.com/myfile.aspx?test

the page fails!

How can I prevent this? I think I should analize the first param's type
but
how?

Thanks in advance

E.T.


Nov 16 '05 #4

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

Similar topics

5
by: Alexandre | last post by:
Hi, Im a newb to dev and python... my first sefl assigned mission was to read a pickled file containing a list with DB like data and convert this to MySQL... So i wrote my first module which...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
2
by: Thomas Magma | last post by:
Hello, I have an application that generates a HTML document that contains an applet. It places raw data into the PARAM NAME tag. Well, once in a blue moon it places the numeric character...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
0
by: Fao, Sean | last post by:
I recently had the desire to create a CheckBoxColumn (similar to a ButtonColumn) that I could add to a DataGrid. I believe the 2.0 framework already includes such a type; however, this is for an...
13
by: trpost | last post by:
I am looking to make a small web app that will return the status of a website from the client browser. I tried this with AJAX and it worked great locally, but did not work for remote users...
11
by: Bob Altman | last post by:
Hi all, I want to write a generic class that does this: Public Class X (Of T) Public Sub Method(param As T) dim x as T = param >3 End Sub End Class
0
by: buntyindia | last post by:
Hi, I have a very strange problem with my application. I have developed it using Struts. I have a TextBox With Some fixed value in it and on Submit iam passing it to another page. <html:form...
1
by: Frank van Bortel | last post by:
R.H. Nadorp wrote: Could it be you NLS_LANG settings expect a "," as numeric separator? Try to make the NLS_NUMERIC_CHARACTERS to be the same at both (client, server) sides, use an alter...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.