Click here to Skip to main content
15,749,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello my friends...
I have an Access database including table .. that table have an "Yes/No" field "it's name: IsHere" that is meaning "True/False" in C#. on the other hand I created a windows form using Visual C#
including DataGridView... In "load" event for this Form I'll fill this DataGridView from my access database .. now I want to left click on checkbox in datagridview at "IsHere" to check or uncheck this then update database after this click to change between "True / False" value in database using DataGridView..
I hope I explained my problem clearly, If not, I am sorry but my English not good very well...
thank you so much my friends <3 .

You could show your code instead of explaining it, you know.
As you don't I have to make some assumptions.

Hopefully you have a DataSet[^], or DataTable, as your data layer and then you use a DataAdapter[^] as a bridge between your database and the DataSet. See also Populating a DataSet from a DataAdapter[^]

Then you should use a BindingSource[^] between the DataSet and your DataGridView[^]. This makes it easier to filter the data and connect the data members to your Windows Form components.

To update or insert data when a value in the DataGridView is change you can use the event DataGridView.OnCellValueChanged[^].

Inside the event you can now check if the DataRow is new or changed and you can take the proper action to either insert or update the data. Here you can also use the DataAdapter, see Updating Data Sources with DataAdapters[^]

So, this was a long answer, but as you are not showing what you have done there is no other way.
Share this answer
So write the change event of checkbox and inside that connect to the database and execute a query which will update the yes/no column value.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900