Use OleDbDataReader to read data from 'select' command : OleDbDataReader « Database ADO.net « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. 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# / C Sharp
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 Tutorial
VB.Net » Database ADO.net » OleDbDataReaderScreenshots 
Use OleDbDataReader to read data from 'select' command
Use OleDbDataReader to read data from 'select' command

Imports System
Imports System.Data
Imports System.Data.OleDb

public class MainClass
   Shared Sub Main()

      'Create Connection object
      Dim thisConnection As New OleDbConnection _
         ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
          "Data Source=Employee.mdb")

      'Create Command object
      Dim thisCommand As New OleDbCommand _
         ("SELECT ID, FirstName FROM Employee", _
          thisConnection)

      Try
         ' Open Connection
         thisConnection.Open()
         Console.WriteLine("Connection Opened")

         ' Execute Query
         Dim thisReader As OleDbDataReader = thisCommand.ExecuteReader()

         While (thisReader.Read())
            Console.WriteLine("FirstName: {0} {1}", _
               thisReader.GetValue(0), thisReader.GetValue(1))
         End While

      Catch ex As OleDbException
         ' Display error
         Console.WriteLine("Error: " & ex.ToString())
      Finally
         ' Close Connection
         thisConnection.Close()
         Console.WriteLine("Connection Closed")
      End Try   
   End Sub
End Class

           
       
Employee.zip( 7 k)
Related examples in the same category
1. Use OleDbDataReader to read dataUse OleDbDataReader to read data
ww___w.j__a_v__a___2___s._c_o___m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.