c# - How to select a field with linq on datarow -


i have linq query :

string title = datarow r in (oledb.dataitems.tables[0]).rows select r.title; 

and i'd extract field title (from database) on row (rows 1, not more, that's put on string , not in string[].

how can it?

vstudio says datarow doesnt contain definition of title, field title exist on database.

i making confusion :)

as frédéric hamidi said, don't need linq.

however, if still want way (overkill) , know there single table single row, do:

dataset data = new dataset();  var table = (from in data.tables.cast<datatable>() select a).single();  var row = (from in table.rows.cast<datarow>() select a).single();  string title = row.field<string>("title"); 

or

dataset data = new dataset();  var table = (from in data.tables.cast<datatable>() select a).singleordefault();  var row = (from in table.rows.cast<datarow>() select a).singleordefault();  string title = row.field<string>("title"); 

i used dataset because don't know how object structured.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -