Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
190 views
in Technique[技术] by (71.8m points)

mysql - How can I check if data in dataset is updated and catch updated data? C#

I have timer-function. It handles data from sql database every N time (it's doesn't matter actually what time). The subsequent algorithm does not work. Or I don't know how to make it work.

  1. I put data into Dataset.
const string query = "SELECT id FROM SomeTable LIMIT 100";

await using var cmd = new MySqlCommand(query, connection);
var sqlAdapter = new MySqlDataAdapter(cmd);
sqlAdapter.TableMappings.Add("Table", "SomeTable");

sqlAdapter.Fill(_mapping);

_mapping.AcceptChanges();

Where _mapping is dataset.

  1. If this is the first filling of the dataset, then just fill it. If this is not the first filling, then try to update the data in it. I tried to use sqlAdapter.Update(_mapping). But it doesn't update any data Or I cant get updated data. I tried fill it again and check _mapping.hasChanges(DataRowState.Modified | DataRowState.Added)) But it hasn't any changes.

So how can I fill dataset and catch changed or added rows while I get data from Database? Or may be I need to use another things like dataTable or something else?

question from:https://stackoverflow.com/questions/65875827/how-can-i-check-if-data-in-dataset-is-updated-and-catch-updated-data-c-sharp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...