I am using Visual Basic.NET 2003. I am using an access Database using the oledbdataadaptor / connection. In my access database I have a bunch of yes/no datatypes that I need to bind with checkboxes in my visualbasic form. After I configure the dataadaptor and then proceed to create the dataset, I get an (1181): 'Convert' is not a member of 'Boolean' error message within my datasetfile.vb file. In order to rid of this error message I have to replace all instances of system.convert.dbnull to convert.dbnull. These SHOULD NOT be DBnull! The code that has the error message is generated by .NET when I generate my dataset. In my form load I have the binding code to bind the controls. I'm able to bind to textboxes without any problems with the "Text" property in my code. However when I use try to use the "Text" property for the binding of checkboxes it won't read or write the boolean values. When I try changing the checkbox binding property to "checked" I get an error message stating that I cannot cast DBnull to other types. Now please don't be confused as to WHY I would want these database values DBNULL, I don't want them DBnull. They should either be 0 or 1 / True or False respectively.
In conclusion I'm wondering what I need to do in order to get these checkboxes to bind correctly so that they are read or wrote correctly. As of right now (with the "Text" binding property) when I select a checkbox and write back to the database, its value remains 0, when in fact it should be 1. When I have the "Checked" binding property it throws an invalid cast exception. Is it the vb.net code that is generated when I create my dataset or is it my control binding code, or what? THe code is below as followed.
VB.NET generated code for the created dataset:
Public Function IsBatteryNull() As Boolean
Public Sub SetBatteryNull()
Me(Me.tableEquipment_Service_Log.BatteryColumn) = System.Convert.DBNull 'THIS IS THE LINE THAT HAS the error message.
Control binding code in frmload:
dim pbndtemp1 as binding
pbndtemp1 = New Binding("text", pdtscanner, "Battery")