preetha rs

preetha rs

  • NA
  • 1
  • 0

How to retrieve records from a Datatable

Oct 19 2008 2:34 AM

Hi,

Can anyone tell me how to retrieve record values from a datatable?.My requirement is like:

Within a for loop I am executing different stored procedures and storing records in a datatable so that i cannot specify paticular column names.i want to write the first row values of each result into a log file.(application is windows service)
Code is :


DataTable dtTransID = new DataTable();
DBConnect();
string sp=" exec "+storedProcedure+" ";
dtTransID =mDB.RunSp(sp);
if(dtTransID.Rows.Count >0)
{
for(i=0;i<dtTransID.Rows.Count;i++)
{
if (storedProcedure!=null)
{
message = message + Datetime.Now+ "\n + dtTransID.Rows[0] +, - ";
message = message + dtTransID.Rows[0] + ",";
Globals.log.logMessage(message);

}

dtTransID.Rows[0] -This line is returning 'system.data.rows' not any records.
Please help me..
Thanks in advance


Answers (1)