函数:
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()