简体   繁体   中英

How to save cell changes from a datagrid to a SQL Server database?

I have loaded data from an Excel sheet via SqlBulkCopy into a SQL Server 2016 database. Then I have loaded this table into a datagrid in C# & WPF.

Some cells are empty, and if I write something in them, I want to immediately (right after I pressed Enter or click on another cell) update my database.

I've looked up many solutions on the internet but none of them helped me.

Thank you in advance and have a nice day!

You can use your datagrid's events:

Leave : Occurs when the DataGridView loses focus;

CellLeave : Occurs when a cell loses focus, ie it's no longer the current cell;

RowLeave : Occurs when a row loses focus and is no longer the current row;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM