VBA操作ACCESS

tech2022-07-30  167

Option Compare Database Option Explicit Sub Open_Ado_RS_Recordset() Dim rs As ADODB.Recordset, kfml, kfrq Set rs = New ADODB.Recordset rs.ActiveConnection = CurrentProject.Connection rs.CursorType = adOpenKeyset rs.LockType = adLockOptimistic rs.Open "select * from 开发;" Do While Not rs.EOF If Not IsNull(rs!开发日期) Then 'Debug.Print rs!Id & vbTab & rs!开发目录 & vbTab & rs!开发日期 Else kfml = rs!开发目录 If Mid(kfml, 1, 1) = "V" Then rs!开发日期 = DateSerial(Mid(kfml, 2, 4), Mid(kfml, 6, 2), Mid(kfml, 8, 2)) End If End If rs.MoveNext Loop rs.Close Set rs = Nothing End Sub Sub test() Dim conn As ADODB.Connection Set conn = New ADODB.Connection conn.Open CurrentProject.Connection Debug.Print conn.Provider conn.Close Set conn = Nothing End Sub Sub Open_Ado_Recordset() Dim rs As ADODB.Recordset Set rs = New ADODB.Recordset rs.Open "select * from 开发;", CurrentProject.Connection Debug.Print rs.GetString rs.Close Set rs = Nothing End Sub

 

最新回复(0)