日期:2012-06-29  浏览次数:20431 次

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