Does ExecuteReader allow you to return a record name?

  • Thread starter Thread starter Steve1 via DotNetMonster.com
  • Start date Start date
S

Steve1 via DotNetMonster.com

Hi all,

I''ve created an OleDbDataReader that will contain the number of records that
the used SQL query will return. I'm then using a while loop to loop while
the OleDBDataReader object has records. I would like to know does the
OleDbDataReader contain the actual information on each record i.e. the fields
in the database and their values? Or does the ExecuteReader command only
contain the number of records present from the used SQL query and no more?
Or am I going the completely wrong way about it??

I need to use the 'Name' field's value of the current OleDbDataReader record
in a following (not present in code snippit) code block. I using an Access
2000 database. Thanks in advance, Steve.

OleDbDataReader obj_ReaderLayoutsPound = obj_SQLLayoutsPound.ExecuteReader();
while( obj_ReaderLayoutsPound.Read())
{
// Is there a property of the OleDbDataReader that will contain the
information of each record?
string str_CurrentRecord = obj_ReaderLayoutsPound.ToString();
}
 
The DataReader contains the result set of the Query in the command
object used to create it. The DataReader has no information on the
underlying tables that may have been accessed by the query. If the
field is in the select statemant you can access it:

str = (string)dr["Name"];
Or better
str = dr.GetStringValue(0); // where 0 is the index of the field
according to the select statement.

I hope I answered your question though I am not sure if I understood
the question.

Cecil Howell
MCT, MCSD, MCAD.NET, MCGFRD.NET
 
Back
Top