update无法找到tablemapping['table']或datatable"table"
我做的一个vb程序,想实现添加一条数据,datagrid里面就显示出这条新加的数据代码如下DimaccstrAsStringolecmd.Connection=conno...
我做的一个vb程序,想实现添加一条数据,datagrid里面就显示出这条新加的数据
代码如下
Dim accstr As String
olecmd.Connection = conn
olecmd.CommandText = "select * from chengji "
adocmd.SelectCommand = olecmd
adocmd.Fill(ds, "chengji")
Try
conn.Open()
If (datacheck(TextBox2.Text)) = True Then
MsgBox("该学号已被使用!!!")
Exit Sub
End If
accstr = "insert into chengji values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "')"
olecmd.CommandText = accstr
olecmd.Connection = conn
olecmd.ExecuteNonQuery()
MsgBox("添加成功!!!!")
adocmd.Update(ds)
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
End Try
Try
Dim changeds As DataSet = ds.GetChanges
adocmd.Update(changeds, "chengji")
ds.AcceptChanges()
Catch ex As Exception
MsgBox(ex.Message)
End Try
请指点。 展开
代码如下
Dim accstr As String
olecmd.Connection = conn
olecmd.CommandText = "select * from chengji "
adocmd.SelectCommand = olecmd
adocmd.Fill(ds, "chengji")
Try
conn.Open()
If (datacheck(TextBox2.Text)) = True Then
MsgBox("该学号已被使用!!!")
Exit Sub
End If
accstr = "insert into chengji values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "')"
olecmd.CommandText = accstr
olecmd.Connection = conn
olecmd.ExecuteNonQuery()
MsgBox("添加成功!!!!")
adocmd.Update(ds)
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
End Try
Try
Dim changeds As DataSet = ds.GetChanges
adocmd.Update(changeds, "chengji")
ds.AcceptChanges()
Catch ex As Exception
MsgBox(ex.Message)
End Try
请指点。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询