dim conn as ADODB.Connection Set conn = New ADODB.Connection dim rs as ADODB.Recordset set rs = New ADODB.RecordsetDim strSQL As String strSQL = App.Path & "\A.mdb" strSQL = Replace(strSQL, "\\", "\")
With conn If .State = 1 Then .Close End If .CursorLocation = adUseClient .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & strSQL .Open End With With rs .Open "SELECT * FROM Table;", conn, adOpenStatic, adLockOptimistic .MoveFirst .MoveLast End With
Set conn = New ADODB.Connection dim rs as ADODB.Recordset
set rs = New ADODB.RecordsetDim strSQL As String strSQL = App.Path & "\A.mdb"
strSQL = Replace(strSQL, "\\", "\")
With conn
If .State = 1 Then
.Close
End If
.CursorLocation = adUseClient
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & strSQL
.Open
End With With rs
.Open "SELECT * FROM Table;", conn, adOpenStatic, adLockOptimistic
.MoveFirst
.MoveLast
End With
rs.CursorType = adOpenStatic
rs.LockType = adLockOptimistic
rs.Open "SELECT * FROM Table;", conn
rs.ActiveConnection = false
With rs
.AddNew
!name = strName
!phone = strPhone
.Update
.Book = .LastModified
End With
这样怎么不行?
有的人别误导别人了,本来是个简单的问题。
.AddNew !name = strName
!phone = strPhone
.Update
.Book = .LastModified
End With
'新增
.AddNew (DAO、ADO中的用法)
'修改
.edit (DAO中的用法,ADO中不要)
!name = strName
!phone = strPhone
.Update
.Book = .LastModified
End With
Item not found in this collection.
With rs
.AddNew
!name = strName
!phone = strPhone
.Update
.Book = .LastModified
End With
就可以了,还需要.edit干身们
.AddNew
!name = strName
!phone = strPhone
.Update
.Book = .LastModified
End With
其中Data1为Data控件。