Help with syntax to retrieve a data from dataset's table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I need to get the value for the 1st record (there is only one row in this
table at all time) for the column name LogFilePath. I got the ado.net and
the dataset fill and the table created("Path"). But I can't find the syntax
on how to get the value. Appreciate it if someone can help me out there.

Thanks,
Alpha
 
Alpha,

Once you have the table, you can do this:

// Assume table is the DataTable.
// This is the row. Since the
// value is in the first row, you can just pass that to the table's indexer.
DataRow row = table.Rows[0];

// Get the value.
string path = (string) row["LogFilePath"];

Or, you can condense it into this:

// Get the value.
string path = (string) table.Rows[0]["LogFilePath"];

Hope this helps.
 
Thank you.

Nicholas Paldino said:
Alpha,

Once you have the table, you can do this:

// Assume table is the DataTable.
// This is the row. Since the
// value is in the first row, you can just pass that to the table's indexer.
DataRow row = table.Rows[0];

// Get the value.
string path = (string) row["LogFilePath"];

Or, you can condense it into this:

// Get the value.
string path = (string) table.Rows[0]["LogFilePath"];

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Alpha said:
Hi, I need to get the value for the 1st record (there is only one row in
this
table at all time) for the column name LogFilePath. I got the ado.net and
the dataset fill and the table created("Path"). But I can't find the
syntax
on how to get the value. Appreciate it if someone can help me out there.

Thanks,
Alpha
 
Back
Top