Blue Theme Orange Theme Green Theme Red Theme
 
Team Foundation Server Hosting
Home | Forums | ASP.NET 2.0 Tutorials | Web Services | How Do I...? | Class Browser | WPF Quick Starts | Advertise with Us
 | Consulting  
Submit an Article Submit a Blog 
Search :       Advanced Search »
Home » Blogs Home » Blog Detail

Copy data from Recordset to DataTable in .net

 by Ankur Gupta on Jul 23, 2010

Copy data from Recordset to DataTable in .net
Comments: 0 Views: 3946 Printable Version 

Copy data from Recordset to DataTable in .Net

You can copy data from Recordset to DataTable by using the following code..

            ADODB.Connection oConn = new ADODB.Connection();

            oConn.Open("Connection String", "", "", 0);

            string strQuery = "SELECT * FROM [" + System.IO.Path.GetFileName(strFileName) + "]";

            ADODB.Recordset rs = new ADODB.Recordset();

            System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();

            DataTable dt = new DataTable();

            rs.Open(strQuery, " Connection String,                ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, 1);

            adapter.Fill(dt, rs);

            return dt;

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
 
What do you say about this post? Post a comment here
*Title:
*Comment:
 
Comments not available.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor

 Blogger's Profile
Age: 29
Location:
Title: Project Manager
Joined: May 15, 2010
Education: Masters Degree
 More Blogs from this Blogger
No record available
 Latest Blogs
[Video] OnClose Handler
[Video] Storing and Loading the Window and Toolbar position
The Euclidean Algorithm
Swapping Exe Process
How Exe file is Generated by VS2005 C++ Project?
What is Exe
Header files: Multiple Inclusion problem - Solution B
Header files: Multiple Inclusion problem - Solution A
Header files: Multiple Inclusion problem - Reason
Header files: Multiple Inclusion problem
View all »
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.