score:0

2 easy ways without using linq:

using system.io;
using system.data;
using system.data.oledb;

public datarow[] getusers(string path, string id) { datatable dt = new datatable(); if (file.exists(path)) { using (oledbconnection con = new oledbconnection(string.format("provider=microsoft.jet.oledb.4.0;data source={0};extended properties=excel 8.0", path))) { oledbdataadapter da = new oledbdataadapter(string.format("select * from users", id), con); da.fill(dt); } } string expression = string.format("{0} = '{1}' and {2} <> ''", id, "first_name", "last_name"); string sort = "last_name asc"; return dt.select(expression, sort); }

public datatable getusers(string path, string id) { datatable dt = new datatable(); if (file.exists(path)) { using (oledbconnection con = new oledbconnection(string.format("provider=microsoft.jet.oledb.4.0;data source={0};extended properties=excel 8.0", path))) { string expression = string.format("{0} = '{1}' and {2} <> ''", id, "first_name", "last_name"); oledbdataadapter da = new oledbdataadapter(expression, con); da.fill(dt); } } return dt; }


Related Query

More Query from same tag