Register
|
Articles
|
Questions
|
Projects
|
Asp.Net Tips
|
Free Magazines
|
Tutorials
|
Search
|
Write to us
|
Login
Search
Articles
Asp.Net 2.0
AJAX
ADO.Net
C#
Javascript
Books
Asp.Net 2.0
AJAX
ADO.NET
C#
JavaScript
MS SQL Server
SilverLight
VB.NET
XML
Web Service
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
How to Convert a SqlDataReader To a DataTable or DataSet in Asp.Net?
Posted by
Moderator1
on
10/11/2008 8:42:29 AM
5645
Views
To convert a SqlDataReader to DataTable or DataSet, use DataTable's Load method. Just look at the sample block of statements below.
string sql = "Select * from MyTable";
SqlCommand cmd = new SqlCommand(sql, MyConnection);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dt = new DataTable();
//Load the SqlDataReader object to the DataTable object as follows.
dt.Load(dr);
Response.Write(dt.Rows.Count.ToString());
Thats it.
Post New Tips/Tricks
View all Tips/Tricks
Featured Resources:
Programmers Heaven C# School Book - Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Easing the Migration to Microsoft SQL Server 2005
There are many business and technological reasons for making the move to SQL Server 2005 and SQL Server 2005 Enterprise Edition. In tandem with 64-bit computing platforms, SQL Server 2005 can boost performance by 30% in certain instances, deliver a better database management structure and bolster infrastructure security.
100% Free Subscription until Stock lost.
View complete list.
Sponsored by
Home
About us
Contact Us
Links
Advertise
Privacy Policy
Copyright ©
2012
. www.AspdotnetCodes.com. All rights reserved.