PDA

Click to See Complete Forum and Search --> : Do I need to convert request.QueryString to Long?


diban
Sep 16th, 2005, 05:10 AM
Hi

I am using a variable in my calc.aspx file to do some calculations:

Dim mLogKey as Long
Dim mBase as Long

mLogKey = Request.QueryString("LogKey")
mBase=Request.QueryString("Base")

I get my value from another form in another file that calls this file as something like this:

action="calc.aspx?LogKey=21&Base=3.14"


I get the following compile error:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

theData=request.QueryString("LogKey")

Do I need to Convert the String into Int/Long?

Thanks

Diban

aconybeare
Sep 16th, 2005, 11:35 AM
Diban,

I'm no expert but I would say yes you do

something like -
You may need to check they're not null before calling "CLng" else you'll get an error, also ensure they're actually numbers

mLogKey = cLng(Request.QueryString("LogKey"))
mBase= cLng(Request.QueryString("Base"))

Also if you've not done it already you should turn option Strict on, which will prevent you from making these type of errors when you build your page

On the main toolbar click Project - [ProjectName] Properties - Select build from the list on the left - then turn on "Option Strict"

Hope this helps

Cheers Al