VB+ACCESS当前记录集不支持更新.这可能是提供程序的限制,也可能是选定锁定类型的限制
ImportsADODBPublicClassForm2DimaAsNewADODB.ConnectionDimbAsNewADODB.RecordsetPrivateS...
Imports ADODB
Public Class Form2
Dim a As New ADODB.Connection
Dim b As New ADODB.Recordset
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If Not TextBox1.Text = "" Then
Button1.Enabled = True
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim cnStr As String = "Provider=microsoft.ace.oledb.12.0;Persist Security Info=False;Data Source=C:\Users\lenovo\Desktop\WindowsApplication3\hospital (1).accdb;Persist Security Info=False"
a.Open(cnStr)
Dim sql As String = "select * from patient ", adOpenKeyset, adLockOptimistic
b.Open(sql, a)
b.AddNew()
b.Fields(0).Value = TextBox1.Text
b.Fields(1).Value = TextBox2.Text
b.Fields(2).Value = ComboBox1.Text
b.Fields(3).Value = TextBox4.Text
b.Fields(4).Value = ComboBox2.Text()
b.Fields(5).Value = ComboBox3.Text
b.Update()
End Sub
addnew处一直提示出错。。。 展开
Public Class Form2
Dim a As New ADODB.Connection
Dim b As New ADODB.Recordset
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If Not TextBox1.Text = "" Then
Button1.Enabled = True
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim cnStr As String = "Provider=microsoft.ace.oledb.12.0;Persist Security Info=False;Data Source=C:\Users\lenovo\Desktop\WindowsApplication3\hospital (1).accdb;Persist Security Info=False"
a.Open(cnStr)
Dim sql As String = "select * from patient ", adOpenKeyset, adLockOptimistic
b.Open(sql, a)
b.AddNew()
b.Fields(0).Value = TextBox1.Text
b.Fields(1).Value = TextBox2.Text
b.Fields(2).Value = ComboBox1.Text
b.Fields(3).Value = TextBox4.Text
b.Fields(4).Value = ComboBox2.Text()
b.Fields(5).Value = ComboBox3.Text
b.Update()
End Sub
addnew处一直提示出错。。。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询