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
请高手指点下 展开
程序代码如下:
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
请高手指点下 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询