hi,
i want to insert data from listview control into database on button click . the application is in universal windows application.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anbu ManiPosted Jan 11, 2018, 12:00 AM
Hubert HermanutzPosted Dec 22, 2017, 3:22 PM
myAdapter = new SqlDataAdapter("Select * from TestTable", con);
//
myDataTable = new System.Data.DataTable();
myAdapter.Fill(myDataTable);
//fill ListView
this.ctlListView.ItemsSource = myDataTable.DefaultView;
{
con.Open();
//define update command...
myAdapter.UpdateCommand = new SqlCommand("UPDATE TestTable SET FieldOne = @FieldOne WHERE Id = @Id", con);
SqlParameter p = myAdapter.UpdateCommand.Parameters.Add("@FieldOne", System.Data.SqlDbType.NVarChar, -1, "FieldOne");
p = myAdapter.UpdateCommand.Parameters.Add("@Id", System.Data.SqlDbType.Int);
p.SourceColumn = "Id";
p.SourceVersion = System.Data.DataRowVersion.Original;
//update changes
myAdapter.Update(myDataTable.Select(null, null, System.Data.DataViewRowState.ModifiedCurrent));
Amit KumarPosted Dec 22, 2017, 1:11 PM