c# - How can I update the database with values from the dataset? -
string s = "select number,name table id = 5 , num = 20"; sqldataadapter adapter = new sqldataadapter(s, con); adapter.fill(dset, "abc"); sqlcommandbuilder st = new sqlcommandbuilder(adapter); adapter.update(ds,"abc");
the next code throws exception, saying table abc cannot found
first of all, paddy said, .fill , .update methods uses different dataset's. 1 dset , other 1 ds.
i think exception occurs on adapter.update(ds,"abc"); line because dbdataadapter.fill method creates abc table in dset if doesn't have table named abc.
the fill method supports scenarios dataset contains multiple datatable objects names differ case. in such situations, fill performs case-sensitive comparing find corresponding table, and creates new table if no exact match exists.
but dbdataadapter.update method doesn't that. doesn't create new table in dataset if seek update table doesn't exist.
closest thing .update method search case-sensitive match (which abc in case) , if can't find it, throws exception.
c# database dataset
No comments:
Post a Comment