How to update only changed fields?

I have a data set in which I create a new row in a datatable and fill in 1 or 2 fields. They may not be the same every time.

When I do dataset.update (), all fields seem to be written back. My database database has default values ​​that do not start.

Is there a way to force the data set to only insert the values ​​that I manually changed, which allows the database to "populate default values ​​for other fields"?

I also need the dataset to generate an insert statement.

+3
source share
3 answers

insert ( ) , .

DataSet , , . - , .

, , , , .

, . , , DataSet . , , , .

, , DataSet, , ( ).

. , DataSets , , GetChanges DataSet/DataTable , , . GetChanges - , DataAdapter , , , , .

+1

adapter.FillSchema.

1. .

0

you can set the default value manually using colling

Column.DefaultValue = defaultValue;

to generate an insert statement, you can use the CommandBuilder class

new SqlCeCommandBuilder (dAdapter);

0
source

Source: https://habr.com/ru/post/1703685/


All Articles