c# - Selecting multiple columns from a DataTable -


my code :

 productrangesfornewrowsdt = productrangesdt.select("product_name, min_quantity, max_quantity, comission_template provider_id = " + provider_id).copytodatatable(); 

where productrangesfornewrowsdt datatable , productrangesdt datatable contains these columns:

product_id product_name provider_id.provider_name min_quantity max_quantity comission_template 

i getting error :

syntax error in expression.

the datatable.select returns array of datarow providing columns exist in datatable return columns in row anyway. .select used where clause can this:

datarow[] rows = productrangesdt.select("provider_id = " + provider_id); 

and use whatever method rows target data table.

to columns want, should derive dataview data table, copy data table , query new set.

dataview view = new dataview(productrangesdt); datatable dtquerytable = view.totable(false, new string[] { "provider_id", "product_name", "min_quantity", "max_quantity", "comission_template" });  datarow[] rows = dtquerytable.select("provider_id = " + provider_id); 

having re-read this, other way. query have, make data table of new filtered set, , use dataview extract columns want.

edit

to only columns want, try other way

datatable dtfiltered = productrangesdt.select("provider_id = " + provider_id).copytodatatable();  dataview view = new dataview(dtfiltered); datatable dtspecificcols = view.totable(false, new string[] { "product_name", "min_quantity", "max_quantity", "comission_template" }); 

the above isn't tested, it's quick-shot reply.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -