Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
C#,.NET Category Code
Real Name
:
SharingCode.NET User
Subject
:
How to run through multiple DataReader results
Description
:
You can save code by piling SQL statements into one SqlCommand and then getting a DataReader with multiple result sets. This code shows you how to run through these.
/* using System.Data; using System.Data.SqlClient; */ SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["con"]); con.Open(); SqlCommand cmd = new SqlCommand("SELECT TOP 3 * FROM Employees ORDER BY LastName;SELECT TOP 3 * FROM Employees ORDER BY LastName DESC",con); SqlDataReader dr = cmd.ExecuteReader(); do { while(dr.Read()) { System.Diagnostics.Debug.WriteLine(dr["LastName"]); } } while(dr.NextResult()); con.Close();
Rating
:
0.00
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks