2 Replies - 1496 Views - Last Post: 30 December 2011 - 12:57 PM

#1 Yo!  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 83
  • Joined: 03-September 11

Select value (bit) if exists

Posted 24 December 2011 - 08:33 AM

Okay here's the problem.
I need to select a boolean value from a table.
The value might not exist yet.
If it doesn't exist, what can I do to tell the difference while returning that value to my vb.net application.
Thanks in advance,
Is This A Good Question/Topic? 0
  • +

Replies To: Select value (bit) if exists

#2 Duckington  Icon User is offline

  • D.I.C Addict

Reputation: 172
  • View blog
  • Posts: 615
  • Joined: 12-October 09

Re: Select value (bit) if exists

Posted 24 December 2011 - 09:37 AM

Not sure exactly what you mean... You mean the record in the database might not exist? Or that the field in that row might be null?

If the record doesn't exist, then you could simply do something like:

Caution: Psuedo-Code ahead:
SELECT = query("SELECT * FROM `table` WHERE `value` = VALUE")
ROWS = number_of_rows(SELECT)
if(ROWS == 0)
// Do whatever you want when the row doesn't exist

Or if you mean if the field itself is null and doesn't contain this boolean value, you could look into using either:

Was This Post Helpful? 0
  • +
  • -

#3 Ionut  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 386
  • View blog
  • Posts: 1,057
  • Joined: 17-July 10

Re: Select value (bit) if exists

Posted 30 December 2011 - 12:57 PM

you can make a simple select from table and from vb.net make the checks
from Table

if there is no value in table, select will return NULL.
From vb.net all you have to do is to check the value from datareader(I suppose you use ADO.NET) equals DBNull.Value. If not, cast to bool. If yes, show a message or whatever you have to do.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1