boolean field check

Posted on 2005-04-03
Medium Priority
Last Modified: 2010-04-23
How to check if field in access database is set to true or false through code? For example, I would like to do something like ..

if field = true then
... perform some action
end if
Question by:whittlephilip
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
LVL 14

Expert Comment

ID: 13693712
Have you got records from Access through dataadapter or DataReader ?
if you use dataadapter to fill dataset:
  Dim dRow as DataRow = mydataset.Tables("mydatatable").Rows(rowIndex)
  If Not IsDbNull(dRow(BoolCol")) AndAlso dRow("BoolCol") Then  'same effect as "If Not IsDbNull(dRow(BoolCol")) AndAlso dRow("BoolCol") = True Then "
  End If

If you use DataReader:
  Dim dr as DataReader
  'execute datareader
  If NOT dr IS Nothing Then
     If dr("BoolCol") Then    'Same as "If dr("BoolCol") = True Then"
     End If

Author Comment

ID: 13696603
Hi amyhxu

I appreciate your attempt to help me. At run time I kept getting the error message saying there was no row at position 0.

At this point I really don't care ;-) This was so much easier in VB6, and can't understand why its become so complex. I guess I'll stick with vb6.
LVL 14

Accepted Solution

amyhxu earned 750 total points
ID: 13702694
You got that error because there was nothing in the dataset, which means your dataadapter or datacommand returns nothing or they were not working.
Take a look at http://www.homeandlearn.co.uk/NET/nets12p4.html . It's a step by step example. Once you get used to vb.net, you'll feel comfortable and more powerful working with vb.net.

Author Comment

ID: 13732809
Hi amyhxu

Good tip. If I may elaborate, I am making headway, thanks to your tip. But I do have one more piece to this question. In the dRow declaration

-- Dim dRow as DataRow = mydataset.Tables("mydatatable").Rows(rowIndex) --

Each rowIndex is called randomly by another function. How should I approach the rowIndex if it is random instead of fixed?

Thanks for you support.


Author Comment

ID: 13734917
Hi ... I think I fixed my problem with random row selection.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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