String was not recognized as a valid Boolean

G

Guest

Hi
I'm passing parameters to a stored procedure in sql2000 from asp.net page
I'm using the same coding technique as in "ASP.NET Starter Kits" to discover the stor proc parameters, but I'm getting
this error :"String was not recognized as a valid Boolean
If I call the same stor proc from the query analyser with the same parameters that the web form pass, the query run succefully without error

thank you for help
 
W

William Ryan eMVP

Can you post the code you're using?

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
tony said:
Hi,
I'm passing parameters to a stored procedure in sql2000 from asp.net page.
I'm using the same coding technique as in "ASP.NET Starter Kits" to
discover the stor proc parameters, but I'm getting
this error :"String was not recognized as a valid Boolean"
If I call the same stor proc from the query analyser with the same
parameters that the web form pass, the query run succefully without error.
 
M

Miha Markic [MVP C#]

Hi tony,

Are you passing a string when boolean is expected?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

tony said:
Hi,
I'm passing parameters to a stored procedure in sql2000 from asp.net page.
I'm using the same coding technique as in "ASP.NET Starter Kits" to
discover the stor proc parameters, but I'm getting
this error :"String was not recognized as a valid Boolean"
If I call the same stor proc from the query analyser with the same
parameters that the web form pass, the query run succefully without error.
 
K

Kevin Yu [MSFT]

Hi Tony,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you are receiving an error which says
"String was not recognized as a valid Boolean" in your application. If
there is any misunderstanding, please feel free to let me know.

Generally, this can be caused by many reasons. To this senario, I
suggestion you check all the "true" or "false" values to ensure that they
are lowercased. Or you are trying to convert non-Boolean string values to
boolean. If that still doesn't work, could you please paste your code and
let us know which statement throws the exception?

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
G

Guest

here is how the parameters are passed to the stor proc

dim ct() as string={"ct_string","ct_int","ct_boolean"}
dim ctValues(2) as strin
ctValues(0)=request.form("ct_string") ' text fiel
ctValues(1)=request.form("ct_int") ' text fiel
ctValues(2)= iif(request.form("ct_boolean") ="",0,1) ' ct_boolean is a checkBox on the web pag

cls_SqlHelp.ExecuteNonQuery(ConnectionString, "storProc_name", ctValues
.... ..... .......
and the rest is exactly the same as in "SQLHelper.vb" classe from "ASP.NET Starter Kits"

I might be doing wrong when passing the values in a string array, but how can I pass them different than that ??

thanks for hel
 
M

Miha Markic [MVP C#]

Why don't you convert values to required types?
Convert.Toxxx
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

tony said:
here is how the parameters are passed to the stor proc:

dim ct() as string={"ct_string","ct_int","ct_boolean"}
dim ctValues(2) as string
ctValues(0)=request.form("ct_string") ' text field
ctValues(1)=request.form("ct_int") ' text field
ctValues(2)= iif(request.form("ct_boolean") ="",0,1) ' ct_boolean is a checkBox on the web page

cls_SqlHelp.ExecuteNonQuery(ConnectionString, "storProc_name", ctValues)
... ..... ........
and the rest is exactly the same as in "SQLHelper.vb" classe from "ASP.NET Starter Kits".

I might be doing wrong when passing the values in a string array, but how
can I pass them different than that ???
 
K

Kevin Yu [MSFT]

Hi Tony,

I don't think that we can check the parameter type at runtime. The type of
the parameter is defined at design time. So could you try to take Miha's
suggestion to convert it explicitly?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top