Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2003, 07:17 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data binding a check box

I have a simple Access table which has a boolean column.
How can I bind this boolean column to a checkbox in a datagrid ?

Any pointers ?
 
Old January 21st, 2005, 02:18 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No time for even bad golf here. No solution is posted yet but allow me to add more detail from my app. VBN documentation states that the checkbox is bound with simple data binding like most other controls. My Access checkbox field default is set to FALSE (for new records); yet when the table is loaded into the dataset and displayed in the datagrid, it appears in the indeterminate state (checked but dimmed). When the Checkbox is checked on the running form and updates are written back to the original table, no check in that field appears there. In the form's Checkbox properties, Checked is set to FALSE, CheckState to UNCHECKED and ThreeState to FALSE. But when the DataBinding "Checked" is changed from "None" to the orignal table field name, NO data appears in the datagrid -- completely blank; not even datagrid lines are there when the form is run. Also, the navigation buttons start throwing exceptions. When the binding is reset to "None," all the records and grid lines reappear but the Checkbox is shown again in the indeterminate state. Thanks in advance for advice here.
 
Old January 21st, 2005, 02:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

correct me if im wrong, but when you put any default value on access it only work inside access...

any way, doesn't know it this help, but maybe you have to set the default type of data for that column to boolean and specify to work them upside down???

HTH

Gonzalo
 
Old January 21st, 2005, 02:46 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Gonzalo -- thank you for an instant response! -- and for the tip on Access field properties. Per your suggestion, I reset the default state to blank; the Data Type is Yes/No (Access Help definition: Yes/No -- a field that contains only one of two values {Yes/No, True/False, or On/Off}- 1 bit), so it is Boolean by nature. Rerunning the app made no difference in the behavior I described in the previous posting. Any other suggestions?
 
Old January 21st, 2005, 03:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

if you try to put the column like it was text what does it give to you... i didnt worked to much with grid in .net.. im just shooting ideas...


HTH

Gonzalo
 
Old January 21st, 2005, 04:36 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Gonzalo -- just like talking real time here. I did not mention previously that textboxes work -- can read and write data to the table and all text appears properly in the datagrid. Encountered the problem when adding a new control -- the Checkbox -- to the form. I'm new to VBN and Access and getting nervous about proceeding with the platform if it's this hard to add what should be a simple Boolean element. Will I encounter such difficulties with other controls that will be added later, like combo and listboxes? Once again, I appreciate your time thinking about it and submitting replies.
 
Old January 21st, 2005, 04:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

mmm.. all i was thinking was to play with the grid, not the database...

i think the grid is taking the data unproperly.. maybe you can try telling the grid that that particular field is text (not boolean) to see what happend...


HTH

Gonzalo
 
Old January 24th, 2005, 03:26 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Gonzalo -- While mousing around on another forum, a solution was posted there; unfortunately, it was for C++, so VBN is not the only development platform encountering difficulties with checkbox controls and data access. The solution suggested a hint, however -- the Boolean nature of the Access field cannot be directly sensed by VBN/ADO .NET as Yes/No, which is how Access treats the data type; rather it looks at it as a 0/1/2 state: False/True/Indeterminate. The latter state is how it appears in my data grid and I cannot write the state I choose for the checkbox (checked/unchecked) back to the table. At least this is a new direction to pursue.
 
Old January 27th, 2005, 12:46 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For anyone else (if any) following this thread, I've made some progress -- reconfiguring the data adapter and regenerating the data set seems to have resynchronized table data types to respective VBN controls. This infers that everytime a new field & control is added/deleted, this must be done -- makes sense (perhaps this will be automatic in VS 2005 but I won't hold my breath). I'm still learning mode with a test app but an experienced developer would plan all the elements in advance and would not encounter this. But it's not over yet -- although the check/nocheck state appears correctly in the datagrid and is written back to the table, I now get a new error message: "Specified cast is not valid." Onward. [Question for "Mr. Access" Gonzalo: the number of deleted records increases constantly with use -- The AutoID Primary Key (not used in this app) increments with each added record, so the size of the table could become large in production use. What is the size limit for Access tables? Can Access be set to automatically purge deleted records even though the datagrid does not display them or must I do it programmatically in VBN?]
 
Old July 20th, 2007, 02:15 PM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Access if a file based server, so it needs something to implement it, in this case you need to write a program to do it. If you change your system to MSDE, then you can create SQL and DTS jobs that will clean your database up on a regular basis.






Similar Threads
Thread Thread Starter Forum Replies Last Post
check box data insert error mateenmohd Classic ASP Basics 3 May 28th, 2007 05:29 AM
capture check box data into mysql osemollie PHP How-To 0 January 30th, 2006 12:18 PM
How to Check DBNull while binding controls narendra_patil General .NET 6 May 13th, 2005 07:20 AM
Weird Combo Box Data Binding Problem [email protected] VB.NET 1 February 12th, 2005 04:52 PM
binding a text box robb Access 1 May 25th, 2004 11:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.