?
Solved

boolean field check

Posted on 2005-04-03
5
Medium Priority
?
178 Views
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
0
Comment
Question by:whittlephilip
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:amyhxu
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
0
 

Author Comment

by:whittlephilip
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.
0
 
LVL 14

Accepted Solution

by:
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.
0
 

Author Comment

by:whittlephilip
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.

Philip
0
 

Author Comment

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

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Suggested Courses

599 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