Access數據庫連接
采用OleDbConnection對象
代碼
Private Function getAccessConnection() As OleDbConnection
Dim dbConnectionString As String =
Data Source=|DataDirectory|\Resources\mag
Dim dbConnection As OleDbConnection = New OleDbConnection(dbConnectionString)
Try
dbConnection
Catch Ex As Exception
End Try
Return dbConnection
End Function
代碼
private Sub fillDataGridView()
Dim sqlStr As String =
Dim DataAdapter As New OleDbDataAdapter
Dim dataSet As New DataSet
Dim DataGridView As New DataGridView
Dim dbConnection As OleDbConnection = getAccessConnection()
If dbConnection
MsgBox(Chr(
Exit Sub
End If
DataAdapter
Try
DataAdapter
DataGridView
Catch Ex As Exception
MsgBox(Err
Finally
dataSet
DataAdapter
dbConnection
dbConnection
End Try
End Sub
PS
Access數據庫文件
調試狀態下
From:http://tw.wingwit.com/Article/program/net/201311/12786.html