初学乍练 vb ADO访问数据库小问题
Dim myTime
Dim myDate
Dim i As Integer
Dim myRs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Private Sub Timer1_Timer()
myTime = Time
myDate = Date
Dim sPath As String
sPath = App.Path & "\shuju.mdb "
If conn.State = adStateOpen Then conn.Close
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ' " & sPath & " ';Persist Security Info=False "
myRs.CursorLocation = adUseClient
myRs.Open "select * from tabel1 order by wdate,wtime ", conn
myRs.AddNew
myRs!aa = 1002
myRs!ss = 90
myRs!dd = 89
myRs!ff = "正常 "
myRs!wdate = CStr(myDate)
myRs!wtime = CStr(myTime)
myRs.Update
myRs.Close
myDb.Close
End Sub
仿照书上一个程序搞的 错误:
从 myRs.AddNew开始
帮一下吧 哪里错了?初学乍练 这第一个小程序就弄了半天出不来啊
[解决办法]
myRs.Open "select * from tabel1 order by wdate,wtime ", conn,1,3试试看
[解决办法]
adOpenKeyset, adLockPessimistic
建议选择3,3来提高效率