SQL Server Data Provider : Data Provider « Database ADO.net « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Database ADO.net » Data ProviderScreenshots 
SQL Server Data Provider
SQL Server Data Provider
 
Imports System
Imports System.Data
Imports System.Data.OleDb

Module OleDbProvider
   Sub Main()
      ' Set up connection string
      Dim ConnString As String = "provider=sqloledb;" & _
         "data source=(local)\SQLEXPRESS;" & _
         "integrated security=sspi;" & _
         "database=MyDatabase"

      ' Set up query string
      Dim CmdString As String = "SELECT * FROM Employee"

      'Declare Connection and DataReader variables
      Dim Conn As OleDbConnection
      Dim Reader As OleDbDataReader

      Try
         'Open Connection
         Conn = New OleDbConnection(ConnString)
         Conn.Open()

         'Execute Query
         Dim Cmd As New OleDbCommand(CmdString, Conn)
         Reader = Cmd.ExecuteReader()

         'Display output header
         Console.WriteLine("Demonstrates the use " & _
            "of the OleDb Data Provider." & ControlChars.NewLine)
         Console.WriteLine("Querying database {0} with query {1}" & _
            ControlChars.NewLine, Conn.Database, Cmd.CommandText)
         Console.WriteLine("FirstName" & ControlChars.Tab & "LastName")

         'Process The Result Set
         While (Reader.Read())
            Console.WriteLine(Reader("FirstName").PadLeft(9& _
               ControlChars.Tab & Reader(1))
         End While

      Catch ex As Exception
         Console.WriteLine("Error: {0}", ex)

      Finally
         'Close Connection
         Reader.Close()
         Conn.Close()

      End Try

   End Sub
End Module

           
         
  
Related examples in the same category
1.OleDb Data ProviderOleDb Data Provider
2.Available ADO.NET Data Providers
3.Obtain the DbProviderFactory for SQL Server.
4.Generic Data Access
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.