getting column from the dataset
-
Hi, I have one dataset, that contain one table now how can i retrieve one column in that table can you send me all possible approachments
-
Hi, I have one dataset, that contain one table now how can i retrieve one column in that table can you send me all possible approachments
if u confirm only one table means ds.dt[tablename].columnname -
-
Hi, I have one dataset, that contain one table now how can i retrieve one column in that table can you send me all possible approachments
Do you really mean 'one column', or do you mean 'one value from a particular row'? If you really mean 'one column', then:
DataColumn column = dataSet.Tables[string tableName].Columns[columnName] or DataColumn column = dataSet.Tables[int tableIndex].Columns[int columnIndex]
If, however, you want the value stored for a particular column in a particular row in a table, then you need to index both the row and the column to get it:object value = dataSet.Tables[string tableName].Rows[int rowIndex][string columnName (,DataRowVersion rowVersion)]
for example (the first method returns the current value in the described row's value list):public object GetValueInRow( DataSet ds, int tableIndex, int rowIndex, string columnName) { return GetValueInRow(ds, tableIndex, rowIndex, columnName, DataRowVersion.Current); } public object GetValueInRow( DataSet ds, int tableIndex, int rowIndex, string columnName, DataRowVersion rowVersion) { return ds.Tables[tableIndex].Rows[rowIndex][columnName, rowVersion] }
Good luck.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-- modified at 2:16 Monday 22nd May, 2006