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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit KumarRank #459 · 5.4K reputationPosted Dec 22, 2017, 8:11 AM EST
Hubert Hermanutz8 reputationPosted Dec 22, 2017, 10:22 AM EST
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));
Anbu ManiRank #206 · 11.7K reputationPosted Jan 10, 2018, 7:00 PM EST