我有一个数据集,我正在添加新行,然后我使用以下命令更新数据集后面的数据库:
DataSetReasons ds = new DataSetReasons();
DataSetReasonsTableAdapters.Data_Tracker_RcodeTableAdapter dta = new DataSetReasonsTableAdapters.Data_Tracker_RcodeTableAdapter();
DataSetReasons.Data_Tracker_RcodeDataTable GRX =
new DataSetReasons.Data_Tracker_RcodeDataTable();
DataRow rowx = GRX.NewRow();
rowx[0] = 111;
rowx[1] = 28;
rowx[2] = "C";
rowx[3] = 12;
rowx[4] = "C";
rowx[5] = 16;
rowx[6] = TextBox2.Text;
GRX.Rows.Add(rowx); //<--- adding the row
dta.Update(GRX); //<-- updating the DB
现在一切正常,除了我想将更新命令放在一个单独的按钮中。当我这样做时,数据库更新不会发生。
任何想法?