SqlDataReader problem

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!
 
M

Marina

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.
 
M

MS News

call dr.Read() again and not dr.NextResult()

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top