用ADO吧!这是我的一段代码,数据库为ACCESS2000Public Sub AddNew()
Dim DataPath As String
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim Ex_time As String
Debug.Assert DataPath <> ""
NotfExist = True
DataPath = App.Path + "\180Record.mdb"
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataPath & ";Mode=ReadWrite;Persist Security Info=False"
conn.Open
Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
rs.Open "180_Contxt", conn, , , adCmdTable
Ex_time = Trim(InputBox("本联系单处理时限为:"))
If Not rs.BOF Then
rs.MoveFirst
Do While Not rs.EOF
If (rs!Name = fileN) Then
NotfExist = False
If Ex_time <> "" Then
rs!ex_date = DateAdd("d", Ex_time, rs!i_date)
rs.Update
End If
End If
rs.MoveNext
Loop
End If
If NotfExist Then
rs.AddNew
rs!Name = fileN
rs!i_date = Date
If Ex_time <> "" Then
rs!ex_date = DateAdd("d", Ex_time, rs!i_date)
End If
rs!cTime = Time
rs!Is_hf = False
rs.Update
End If
rs.Close
conn.Close
End Sub
Dim DataPath As String
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset
Dim Ex_time As String
Debug.Assert DataPath <> ""
NotfExist = True
DataPath = App.Path + "\180Record.mdb"
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DataPath & ";Mode=ReadWrite;Persist Security Info=False"
conn.Open
Set rs = New ADODB.Recordset
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.CursorLocation = adUseClient
rs.Open "180_Contxt", conn, , , adCmdTable
Ex_time = Trim(InputBox("本联系单处理时限为:"))
If Not rs.BOF Then
rs.MoveFirst
Do While Not rs.EOF
If (rs!Name = fileN) Then
NotfExist = False
If Ex_time <> "" Then
rs!ex_date = DateAdd("d", Ex_time, rs!i_date)
rs.Update
End If
End If
rs.MoveNext
Loop
End If
If NotfExist Then
rs.AddNew
rs!Name = fileN
rs!i_date = Date
If Ex_time <> "" Then
rs!ex_date = DateAdd("d", Ex_time, rs!i_date)
End If
rs!cTime = Time
rs!Is_hf = False
rs.Update
End If
rs.Close
conn.Close
End Sub
也可以用DAO 3.5,ADO 2.5(sp5中有,性能比VB自带的2.0好多了),JET 4.0
odbc最为通用了。
jet 4.0 can be use in access97