Access数据库的连接(ADO.NET)

发表于:2007-07-01来源:作者:点击数: 标签:
Imports System.Data.OleDb
Module Module1
    Sub Main()
     @# 首先设置对 System.Data.dll 的引用。
     Dim objConn As New OleDbConnection _
     ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
     "User ID=Admin;" & _
     "Data Source=C:Northwind.mdb")
     objConn.Open()
     Dim objCmd As New OleDbCommand _
     ("SELECT * FROM Products", objConn)
     Dim objDataReader As OleDbDataReader = objCmd.ExecuteReader
     objDataReader.Read()
     Console.Write(objDataReader.Item("ProductName") & ", " & _
     objDataReader.Item("UnitsInStock"))
    End Sub
End Module

原文转自:http://www.ltesting.net