Error reading database bit Boolean field data in C # converting INT and bool

Source: Internet
Author: User

This Boolean type of field in the database is very useful, but when read in C #, many people like to make some mistakes, causing them to run an error.

In practice, there are only two valid methods to read correctly:

int xxx= convet.toint16 (reader["xxx"]);//or Convet.toint32

BOOL xxx= BOOL. Parse (reader["xxx"]);

Other can be error, even if not error, can not guarantee the database settings or operating system problems, resulting in a sudden error!

such as Int. Parse (), sometimes the error is reported:

In System.Number.StringToNumber (String str, NumberStyles options, numberbuffer& number, NumberFormatInfo info, Boolean parsedecimal)
In System.Number.ParseInt32 (String s, NumberStyles style, NumberFormatInfo info)

Error reading database bit Boolean field data in C # converting INT and bool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.