I'm rewriting an IronPython WPF app in C# (for assorted reasons). In IPython, I can just do something like:
rows = dt.GetList()
foreach (row in rows);
ln = row["lastname"] ... etc.
and so forth. Since C# is a lot more picky about data types, I haven't been able to figure out how to get something like the foreach to work, or even to get the plain indexed version (in the MessageBox below) to work. I'm not to the point where I want to turn it into a CollectionView. Have googled up quite a bit of info on how to do something a lot more complex than this - I may want to do that eventually - but for now, just trying to see if I can get my data back into simple Oracle-like data types - strings, Ints, etc. Suggestions appreciated.
OracleDataAdapter da = new OracleDataAdapter(sql, db_connection);
DataTable dt = new DataTable();
da.Fill(dt);
System.Collections.IList rows = ((IListSource)dt).GetList();
MessageBox.Show(rows[0]["lastname"]);
you don't have to convert your datatable, there is already a list of datarow.
With a foreach loop :
You can also access with :
To print the whole table :
With col.DataType, you can retrieve the type ;)
Hope it will help