How to display ms access database data by date after removing duplicates c#

Hi I am using these code to remove duplicates in ms access database

int id, k = 0; con.Open(); DataTable dt = new DataTable(); DataSet ds = new DataSet(); ds.Tables.Add(dt); OleDbDataAdapter da = da = new OleDbDataAdapter("select * from targets", con); //where (SecSym='" + secsym + "')order by Date desc", con); da.Fill(dt); int iRecords = 0; da.Fill(ds, "targets"); for (int i = 0; i < ds.Tables["targets"].Rows.Count; i++) { DataRow row = ds.Tables["targets"].Rows[i]; k++; for (int j = k; j < ds.Tables["targets"].Rows.Count; j++) { DataRow row2 = ds.Tables["targets"].Rows[j]; if (row.ItemArray.GetValue(1).ToString() == row2.ItemArray.GetValue(1).ToString()) { if (row.ItemArray.GetValue(3).ToString() == row2.ItemArray.GetValue(3).ToString()) { string id1 = row2.ItemArray.GetValue(0).ToString(); deletedupes(id1); } } } } con.Close(); MessageBox.Show("Completed"); private void deletedupes(string num) { OleDbCommand c = new OleDbCommand("Delete * from targets where SrNo =?", con); c.Parameters.AddWithValue("SrNo", num); c.ExecuteNonQuery(); }

this is working fine for me

I am using this code to for sorting

OleDbDataAdapter da = new OleDbDataAdapter("select * from targets where (secsym='" + SecSym.Text + "')order by SrNo asc", con);

it is not displaying me the data in listview by date order .

can anyone please say me where i am going wrong.

Thanks In Advance.

Category:c# Time:2011-11-23 Views:0

Related post

Copyright (C), All Rights Reserved.

processed in 0.806 (s). 13 q(s)