grouchyfd
asked on
How do I retrieve boolean data from 1 column of a table in my database?
In my ADO.net app., I have an order form that when the order is completed, the user checks a "Completed" checkbox (boolean data). When this checkbox is checked it removes the order form the open orders list (& does other functions). On this form I have a label that I would like to be visible only when there are open orders. I have tried a datareader & a dataset to try to get this boolean data but I am unable to retrieve just this 1 column's data from the data table.
Dim Con as new Odbc,OdbcConnection
Dim Com as new Odbc.OdbcCommand
Com.CommandText = ("Select Completed from Orders")
Com.Connection = Con
Con.Open()
I believe I have to do a loop thru the rows to get this data. I don't need to put it into any kind of lable or textbox. I just want to be able to read the boolean data so that if there is just 1 open order the open order label will be visible.
Thanks
Dim Con as new Odbc,OdbcConnection
Dim Com as new Odbc.OdbcCommand
Com.CommandText = ("Select Completed from Orders")
Com.Connection = Con
Con.Open()
I believe I have to do a loop thru the rows to get this data. I don't need to put it into any kind of lable or textbox. I just want to be able to read the boolean data so that if there is just 1 open order the open order label will be visible.
Thanks
ASKER
Being a windows app (client/server) I'm not real fluent in asp.net. I'm using visual basic.net. So what your saying I might be able to have the visible property of the label be able to evaluate the true(1)/false(0) data from the column of the database?
Hi grouchyfd,
Apologies for the ASP .Net response, didn't even realise I had switched topic areas.
How do you navigate your VB .Net form records?
If you use a BindingNavigator you could set the visible property of the Label using the RefreshItems Event.
Apologies for the ASP .Net response, didn't even realise I had switched topic areas.
How do you navigate your VB .Net form records?
If you use a BindingNavigator you could set the visible property of the Label using the RefreshItems Event.
Private Sub BindingNavigator1_RefreshItems(sender As System.Object, e As System.EventArgs) Handles BindingNavigator1.RefreshItems
Me.Label1.Visible = Not Me.CheckBox1.Checked
End Sub
Alan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I apologize for the delay. Unfortunately using the checked state of the checkbox only works for an individual record of the form. The logic of filtering the data (from the database) where completed = false and getting that row count works fine becuase it will only retrieve the rows that indicate that they haven't been completed yet. Thank you for helping me with the logic of this.
Open in new window
Or maybe even better, modify your SQL to return a value to be used specifically by the labels visible property.We would have to invert the value of Completed, so if the checkbox is checked, return 0(false) for the calculated field LabelVisible, else return 1(true), we can use a JET Immediate If to do that.
Open in new window
Alan