SqlDataReader problem

  • Thread starter Thread starter Arjen
  • Start date Start date
A

Arjen

Hello,

With my SqlDataReader I select 2 records.

Here is a little bit of my code:
SqlDataReader dr = documents.GetDocuments(ModuleId);

// Load first row into Datareader
if (dr.Read()) {
// Read it!
}

// Load second row into Datareader
if (dr.NextResult()) {
// Read it!
}

dr.Close();

The problem is that the second record dr.NextResult() doesn't work. But
there are two records selected!!!

Why is it not working?

Thanks!
 
If the 2 records are both as a result of one query, then you just need to
call Read again to advance to the next row.

If they are in different record sets, then you need to call Read after
calling NextResult, to advance the next result set to the first row.
 
call dr.Read() again and not dr.NextResult()

You don't have multiple Select in your Query??
 
Back
Top