simple syntax question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arthur

    #1

    simple syntax question

    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.TableN ame("TableAlias ").Rows(i).Item s[/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.S how(DsName.Tabl eName[/color][/color][/color]
    ("ColumnName"). ToString)[color=blue][color=green][color=darkred]
    >>>
    >>>I get the following error:
    >>>
    >>>An unhandled exception of
    >>>type 'System.Invalid CastException' occurred in
    >>>microsoft.vi sualbasic.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]
Working...