c# - how to load datatable from datarow array? -


datatable dt = new datatable(); datarow[] dr = (datatable)dsdata.tables[0].select("some criteria"); dt = (datatable)dsdata.tables[0].clone(); dt.rows.add(dr); //line causing error 

the above code throwing error in bolded line follows

"unable cast object of type 'system.data.datarow' type   'system.iconvertible'.couldn't store in pipelinesubstatusid column.  expected type decimal." 

can me overcome problem

try this:

foreach(var row in dr) {     var r=dt.newrow();     r.itemarray = row.itemarray;     dt.rows.add(r); } 

or

foreach(var row in dr) {     dt.rows.add(row); } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -