Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pass Boolean to a store procedure

Posted on 2016-08-14
5
Medium Priority
?
58 Views
Last Modified: 2016-08-17
hi,

I am trying to pass a value of boolean to a sp. I am getting an error

Failed to convert parameter value from a String to a Boolean.

On the aspx page, I have code as
                                <asp:ListItem value="">Select</asp:ListItem>
                                <asp:ListItem value="True">Yes</asp:ListItem>                         
                                  <asp:ListItem value="False">No</asp:ListItem>

on CS page, I have code as

SqlCom.Parameters.Add("@var", System.Data.SqlDbType.Bit).Value = var.Text.ToString();


The field is a bit data type. Any ideas?  thx

Failed to convert parameter value from a String to a Boolean.
0
Comment
Question by:mcrmg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Steve Groner
ID: 41755607
Bit fields are either 0 or 1 or null.  Change the value in your ASPX to 0 = false and 1 = true.  Thank should help out.
0
 

Author Comment

by:mcrmg
ID: 41755608
thanks for the quick reply. Would it work if the user did not select neither YES nor NO?  thanks
0
 
LVL 1

Accepted Solution

by:
Steve Groner earned 2000 total points
ID: 41755624
You would need to pass the null in that case.  Just make sure your bit field in SQL is capable of allowing nulls as an acceptable value and you should be good.
0
 

Author Comment

by:mcrmg
ID: 41755637
thank you
0
 

Author Closing Comment

by:mcrmg
ID: 41759208
thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question