VB实时错误3251,当前记录集不支持更新

实时错误3251,当前记录集不支持更新,这可能是提供程序的限制,也可能是锁定类型的限制”程序代码如下:DimcnnAsNewADODB.Connection,rstAsN... 实时错误3251,当前记录集不支持更新,这可能是提供程序的限制,也可能是锁定类型的限制”

程序代码如下:
Dim cnn As New ADODB.Connection, rst As New ADODB.Recordset, cmd As New ADODB.Command
Sub ref()
Dim i As Integer
If rst.EOF And rst.BOF Then
MsgBox "空表,请增加记录", vbCritical, "提示"
Exit Sub
End If
For i = 0 To 4
Label1(i).Caption = rst.Fields(i).Name
If rst.Fields(i) <> "" Then
Text1(i).Text = rst.Fields(i)
Else
Text1(i) = ""
End If
Text1(i).Locked = True
Next i
Text2.Text = "记录:" & rst.AbsolutePosition & "/" & rst.RecordCount
End Sub

Private Sub Command1_Click()
rst.MoveFirst
ref
End Sub

Private Sub Command2_Click()
rst.MovePrevious
If rst.BOF Then
rst.MoveFirst
End If
ref
End Sub

Private Sub Command3_Click()
rst.MoveNext
If rst.EOF Then
rst.MoveLast
End If
ref
End Sub

Private Sub Command4_Click()
rst.MoveLast
ref
End Sub

Private Sub Command5_Click()
Dim i As Integer
Text1(i).Locked = False

Text2.Text = "新增记录"
For i = 0 To 4
Text1(i).Locked = False
Text1(i) = ""
Next i
Text1(0).SetFocus
rst.AddNew
End Sub

Private Sub Command6_Click()
Dim i As Integer
rst.Fields(i) = Text1(i).Text
rst.Update
MsgBox "保存成功"
End Sub

Private Sub Command9_Click()
End
End Sub

Private Sub Form_Load()
Dim s As String
s = "Provider=SQLOLEDB.1;Persist Security Info=true;Password=sa;User ID=sa;Initial Catalog=test;Data Source=Server"
cnn.Open s
cnn.CursorLocation = adUseClient
'cmd.ActiveConnection = cnn
'cmd.CommandText = "select * from goods"
'cmd.CommandType = adCmdText
rst.Open "select * from goods", cnn

Call ref
End Sub

请高手指点下
展开
 我来答
何宜校
2010-06-19 · TA获得超过1691个赞
知道小有建树答主
回答量:702
采纳率:0%
帮助的人:968万
展开全部
rst.Open "select * from goods", cnn
最好确定游标和琐的类型,默认的是只读琐
例如可以改为:
rst.Open "select * from goods", cnn,1,3
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式