Selecting rows in DataTable based on Filter Criteria in C# with using OLEDB RRS feed

  • Question

  • User-1210445492 posted
    Hi I am working on a .NET 3.5 application. I want to select a group of rows from a Table based on the Filter Criteria and move those rows to a new DataTable. Table1 has 100 rows -- > Select the Rows from Table1 if Column1 value is "A" or "B" or "C" - - > Move the selected Rows to Table2. Is it possible to move few rows from Table1 to Table2 directly without looping the rows? How to select the group of rows from a Table based on Filter and move to a new Table in C# code? I am using OLEDB My code is like this: sourceFile=@"D:\Users\Desktop\New Data\KO_Consolidated.csv" string strSql = "SELECT * FROM [" + System.IO.Path.GetFileName(sourceFile) + "]"; string strCSVConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.IO.Path.GetDirectoryName(sourceFile) + ";" + "Extended Properties='text;HDR=YES;'"; OleDbDataAdapter oleda = new OleDbDataAdapter(strSql, strCSVConnString); DataTable KODATA = new DataTable(); oleda.Fill(KODATA); DataView dv = new DataView(); DataSet ds = new DataSet(); DataColumn column1 = new DataColumn("WorkInfoType", typeof(string)); KODATA.Columns.Add(column1); dv = new DataView(KODATA); dv.RowFilter = "WorkInfoType='Incident Task / Action' AND WorkInfoSummary='KS'"; return KODATA; But i m not able to get my result. Thanks a lot in advance for your help.
    Friday, August 30, 2013 2:17 AM

All replies