Query more columns and read result set : OleDbDataReader « Database ADO.net « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » Database ADO.net » OleDbDataReaderScreenshots 
Query more columns and read result set
Query more columns and read result set


using System;
using System.Data;
using System.Data.OleDb;

public class ExtractInfo {    
 public static void Main () { 
   String connect = "Provider=Microsoft.JET.OLEDB.4.0;data source=.\\Employee.mdb";
   OleDbConnection con = new OleDbConnection(connect);
   con.Open();  
   Console.WriteLine("Made the connection to the Sales database");
   OleDbCommand cmd = con.CreateCommand();
   cmd.CommandText = "SELECT First_Name, Last_Name FROM Employee ORDER BY First_Name"
   OleDbDataReader reader = cmd.ExecuteReader();
   Console.WriteLine("First_Name\t\tLast_Name");  
   while(reader.Read()) 
     Console.WriteLine("{0}\t{1}",reader.GetString(0), reader.GetString(1));
   reader.Close();
   
   con.Close();
 }
}
           
       
Related examples in the same category
1. Read result set containing all columnsRead result set containing all columns
2. Execute complicated SQL query
3. Read value using OleDbDataReaderRead value using OleDbDataReader
4. Map database column name to OleDbDataReader
5. Reference data in OleDbDataReader by column name
6. Format Data from OleDbDataReader
w___ww__.__j__a_v_a__2___s___.___c___om | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.