locked
Binding A VB CheckBox To MS Access Data Table RRS feed

  • Question

  • Hi:

    I have an Access data table with one of the fields as a "Yes/No" type. The user interface is a VB form.

    I cannot get the binding to work right and the insert and update don't work. This is the code to bind

    the checkbox to the data.

            chkSE_OR2.DataBindings.Add("Checked", bsSE, "SE_OR2_CHK")

    This is part of the insert command code.  

            SE_InsertCommand.Parameters.Add("@SE_OR2_CHK", OleDbType.Boolean, 1, "SE_OR2_CHK")

    This is part of the code for the update command.

            SE_UpdateCommand.Parameters.Add("@SE_OR2_CHK", OleDbType.Boolean, 1, "SE_OR2_CHK")

    I would really appreciate some help here.

    Thanks so much.



    Friday, April 10, 2020 6:41 PM

All replies

  • Hello,

    If the Binding was incorrect you would get a runtime exception so we know that the Binding is correct. Now to peek at what is happening you can subscribe to several DataTable events such as ColumnChanges, TableNewRow etc. or what might be easier is to use GetChanges method of the DataTable.

    Either or will provide insight to what might be transpiring.

    And the parameter add appears proper.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, April 10, 2020 7:06 PM
  • Hi:

    Thanks I will work on it.

    Friday, April 10, 2020 7:21 PM
  • Hi Developer Dude,

    Did you solve your problem? If your question has been answered then please click the "Mark as Answer" Link at the bottom of the correct post(s), so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 14, 2020 9:51 AM
  • In the Forms Designer, right-click the control you want to bind to a field and then click Properties on the shortcut menu.
    On the Value tab, click Choose Field, point to a field set, and then click the field to which you want to bind the control. ...
    Click OK in the Properties box.
    Tuesday, April 14, 2020 10:40 AM
  • If you use a datatable with MS Access, then you normally use an OleDBDataAdapter to get the table and to update the table. 

    Also you use a currency instrument like a binding source to get the current position. 

    You don't use parameters at all, because that is normally all handled by something as an OleDBCommandBuilder or you use a generated strongly typed dataset with your table.

    Using with that insert commands, Updatecomppans and Delete commands is seldom done by persons who use an Access database because that is extremely tricky.

    That all can then be done with a DataAdapter.Update (a little misleading name for SQL fans because it is Inserting, Updating and Deleting).

    Therefore it is probably better to tell how you retrieve your datatable. It is not unlikely that your binding is correct.  


    Success
    Cor


    Tuesday, April 14, 2020 9:46 PM