I'm an "old" programmer but new to ASP.NET.
I want to get a value from the SQL Dataset.
What I would normally do in other environments is iterate through the dataset to get the value I would be intrested in, but I can't figure out how to do this without using a visual data display object like a Grid view.
Typically I want to get a value from the database that I then after manipulating it, like multply by 5, use to format something on the page.
thanks in advance,
Thommie
if you already have created the dataset then its easy to retrieve and iterate through rows.
for each row as datarow in dataset.tables(table index or name, 0 if its only table).rows
dim str as string=row(column name or index).tostring
Next
or
for i as integer=0 to dataset.tables(0).rows.count
var=dataset.tables(0).rows(i)(columnname or index)
next
hope this helps.
Eric
|||
Do you have a compelling reason to use a DataSet? If you are needing to return a single value, I'd look into using ExecuteScalar() off of the SqlCommand object or using an output parameter and getting your value like that. If you need some more explicit examples, let me know.
|||Hi,
You can go through the DataSet using foreach, like
foreach(DataRow dr in DataSet.Table[0].Rows)
{
//use dr[0] to get the first column data.
}
HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!
No comments:
Post a Comment