|
'*******模块
Private Sub Workbook_Open()
Sheet1.Cells(3, 7) = Date '加日期
cn.ConnectionString = "provider=sqloledb;server=erp_yx;database=checkdata;user id=123;password=123"
cn.Open
rs.ActiveConnection = cn
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
rs.LockType = adLockReadOnly
rs.Open "select * from AddPur"
End Sub
'****WORKBOOK
Private Sub Workbook_Open()
Sheet1.Cells(3, 7) = Date '加日期
cn.ConnectionString = "provider=sqloledb;server=erp_yx;database=checkdata;user id=sa;password="
cn.Open
rs.ActiveConnection = cn
rs.CursorLocation = adUseClient
rs.CursorType = adOpenDynamic
rs.LockType = adLockReadOnly
rs.Open "select * from AddPur"
End Sub
'**********按钮
Private Sub 保存_Click()
Dim i As Integer, j As Integer
Dim itemCount As Integer, itemNow As Integer
itemCount = 1000
For i = 5 To itemCount
rs.AddNew
rs("ord") = Cells(i, 1)
rs("part") = Cells(i, 2)
rs("num") = Cells(i, 3)
rs("datime") = Cells(i, 4)
rs("status") = Cells(i, 5)
rs("docno") = Cells(i, 6)
rs("note") = Cells(i, 7)
rs.Update
i = i + 1
Next i
End Sub
以上代码一运行的时候就出现在rs.AddNew这一行错误,错误原因是:运行错误'3251',当前记录不支持更新,可能是提供程序的限制,也可能是选定锁定类弄的限制.
请问各位是为什么???怎么样修改 |
|