vb.net 2008 连接 Access 2003 数据库的问题。

2024-12-25 18:43:26
推荐回答(1个)
回答1:

函数:
Public Function LinkDatabase(ByVal AppPath As String) As String
LinkDatabase = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & AppPath & "\atabase.mdb;Persist Security Info=False;Jet OLEDB:Database Password=''"
End Function

调用:
ADOConn.ConnectionString = LinkDatabase(Application.StartupPath)
ADOConn.CommandTimeout = 10
ADOConn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
ADOConn.Open()
Adors.Open("SELECT * FROM TableName", ADOConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
_Temp=Adors.Fields("Col1").Value
Adors.Fields("Col2").Value="AAA"
Adors.Update()
ADOConn.Close()