vb 当前记录集不支持更新
实时错误‘3251’当前记录集不支持更新。这可能是提供程序的限制,也可能是选定锁定类型的限制。PrivateSubForm_Load()Setconn=NewADODB....
实时错误‘3251’ 当前记录集不支持更新。这可能是提供程序的限制,也可能是选定锁定类型的限制。
Private Sub Form_Load()
Set conn = New ADODB.Connection
rs.CursorType = adOpenStatic
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & App.Path & "\database\txt.mdb"
conn.open
Set rs.ActiveConnection = conn
rs.open ("select * from txt")
rs.MoveFirst
End Sub
*************
Dim X, Y As String, i!
Y = Trim(Text1.Text)
X = Trim(Text2.Text)
If X <> "" And Len(X) < 256 Then
With rs
.MoveFirst
Do Until .EOF()
If .Fields("title") = Y Then
c = MsgBox("此文已存在,请更换。", 0, "亲")
Exit Sub
.MoveNext
Else
.MoveNext
End If
Loop
End With
MsgBox "添加成功,需要重启软件才有效"
sql = "insert into txt(content,[title]) values ('" & X & "','" & Y & "')"
conn.Execute (sql)
rs.Update '*********
End If
If Len(X) >= 255 Then
c = MsgBox("文本中字符数不能超过255", 0, "亲")
End If
End Sub
我想要插入数据后能实时更新,所以加了句 rs.update。但出现了如上的错误。求解 展开
Private Sub Form_Load()
Set conn = New ADODB.Connection
rs.CursorType = adOpenStatic
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.ConnectionString = "Data Source=" & App.Path & "\database\txt.mdb"
conn.open
Set rs.ActiveConnection = conn
rs.open ("select * from txt")
rs.MoveFirst
End Sub
*************
Dim X, Y As String, i!
Y = Trim(Text1.Text)
X = Trim(Text2.Text)
If X <> "" And Len(X) < 256 Then
With rs
.MoveFirst
Do Until .EOF()
If .Fields("title") = Y Then
c = MsgBox("此文已存在,请更换。", 0, "亲")
Exit Sub
.MoveNext
Else
.MoveNext
End If
Loop
End With
MsgBox "添加成功,需要重启软件才有效"
sql = "insert into txt(content,[title]) values ('" & X & "','" & Y & "')"
conn.Execute (sql)
rs.Update '*********
End If
If Len(X) >= 255 Then
c = MsgBox("文本中字符数不能超过255", 0, "亲")
End If
End Sub
我想要插入数据后能实时更新,所以加了句 rs.update。但出现了如上的错误。求解 展开
展开全部
MsgBox "添加成功,需要重启软件才有效"
sql = "insert into txt(content,[title]) values ('" & X & "','" & Y & "')"
conn.Execute (sql)
rs.Update '*********
End If
这段去掉rs.update,要么去掉执行sql那段这样写
rs.addnew()
rs.Fields("content") = "X"
rs.Fields("title") ="Y"
rs.update
sql = "insert into txt(content,[title]) values ('" & X & "','" & Y & "')"
conn.Execute (sql)
rs.Update '*********
End If
这段去掉rs.update,要么去掉执行sql那段这样写
rs.addnew()
rs.Fields("content") = "X"
rs.Fields("title") ="Y"
rs.update
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询