I am trying to add a new word from a text field to a table:
private void addAnswer_Click(object sender, EventArgs e) { // Get a new row from the data table myDataTable.NewRow(); DataRow Row1 = new DataRow(); Row1["Word"] = QuizAnswer.Text; myDataTable.Rows.Add(Row1); // Locate the newly added row currentRecord = myDataTable.Rows.IndexOf(Row1); DisplayRow(currentRecord); // Commit changes to the database UpdateDB(); myAdapter.Fill(myDataTable); }
However, this gives me this strange error:
Error 1 'System.Data.DataRow.DataRow (System.Data.DowRowBuilder)' is unavailable due to protection level
c # datatable
zzwyb89
source share