Connecting Tech Pros Worldwide Help | Site Map

simple syntax question

Arthur
Guest
 
Posts: n/a
#1: Jul 19 '05
DataRow dataRow = dataSet.Tables[0].Rows[0];
string myString = dataRow["MY_COLUMN_NAME"].ToString();

Make sure you have at least one row before you try this.

Arthur[color=blue]
>-----Original Message-----
>Hi Roger,
>Thanks for the try ... I get error that Rows not memeber
>of TableName. I tried various other combinations using
>your format ... but no luck. All I want to do is access
>a data item (without using a control) via code so that I
>can compare/list/calculate/etc. within my program code.
>I filled the dataset using a SQLAdapter ... but simply
>don't know how to programatically get to the data. An
>other ideas are certainly appreciated.
>Thanks!
>[color=green]
>>-----Original Message-----
>>Try:
>>
>>DsName.TableName("TableAlias").Rows(i).Items[/color]
>("ColumnName")[color=green]
>>
>>Where i is the row number of the table you are after.
>>ColumnName would be the actual column name from your
>>orginal table.
>>
>>Hope I understood your question correctly.
>>
>>Another Rookie
>>[color=darkred]
>>>-----Original Message-----
>>>I am trying to access a column within a dataset. I[/color][/color][/color]
can[color=blue][color=green][color=darkred]
>>>display data thru control but when trying to access[/color][/color][/color]
via[color=blue][color=green][color=darkred]
>>>code:
>>>MessageBox.Show(DsName.TableName[/color][/color][/color]
("ColumnName").ToString)[color=blue][color=green][color=darkred]
>>>
>>>I get the following error:
>>>
>>>An unhandled exception of
>>>type 'System.InvalidCastException' occurred in
>>>microsoft.visualbasic.dll
>>>
>>>Additional information: Cast from string "Status" to
>>>type 'Integer' is not valid.
>>>
>>>Can someone give me correct syntax or code example ...
>>>Thanks!
>>>A rookie
>>>.
>>>[/color]
>>.
>>[/color]
>.
>[/color]
Closed Thread


Similar .NET Framework bytes