vb.net連接ACCESS数据库
'導入命名空間
Imports System.Data.OleDb
'定義變量
Dim Sql As String
'OleDb連線
Dim SqlAC As OleDbConnection
Dim CmdAC As OleDbCommand
Dim drAC As OleDbDataReader
'打開OleDb連線
Public Sub OpenAC()
SqlAC = New OleDbConnection(" Provider = Microsoft.Jet.OLEDB.4.0;Data Source = DISK.mdb ")
If SqlAC.State = ConnectionState.Closed Then
SqlAC.Open()
End If
CmdAC = New OleDbCommand(Sql, SqlAC)
drAC = CmdAC.ExecuteReader()
End Sub
'關閉OleDb連線
Public Sub CloseAC()
drAC.Close()
If SqlAC.State = ConnectionState.Open Then
SqlAC.Close()
End If
End Sub
Private Sub A1()
Sql = ("SELECT A1 FROM T8 ")
OpenAC()
drAC.Read()
TextBox1.Text = drAC.Item(0)
CloseAC()
End Sub
轉載于:https://www.cnblogs.com/leme-chen/p/9266942.html
總結
以上是生活随笔為你收集整理的vb.net連接ACCESS数据库的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Occlusion(遮挡剔除)
- 下一篇: Java基础(三)面向对象(下)