Get boolean value from DataTable

How to get a boolean value in a dataset, I am using Visual Studio 2003, I am trying to do the following, but it does not work:

//if product inactive, don't display, and redirect to main page
  if((dbDataSet.Tables["productGeneral"].Rows[0]["Active"].Equals(0)))

I even tried but didn't work:

if((dbDataSet.Tables["productGeneral"].Rows[0]["Active"].toString() == false)

the column name is ["active"], the value in the column is True or False using sql server 2000

please, help

+3
source share
2 answers

You need to send to bool directly and just check using this.

You tried?:

if(((bool)dbDataSet.Tables["productGeneral"].Rows[0]["Active"] == false))

If it is a bool, you want to directly pass the result to bool.

, 0 Int32, . #, . , ToString() , bool, .

+3

   if (Convert.ToBoolean(dbDataSet.Tables["productGeneral"].Rows[0]["Active"]) == true)
   {}
+1

Source: https://habr.com/ru/post/1711363/


All Articles