vb.net使用DataGridView更新数据时出错Update 无法找到 TableMapping['Table'] 或 DataTable“Table”。
vb.net使用DataGridView更新数据时出错Update无法找到TableMapping['Table']或DataTable“Table”。为什么会这样,求大...
vb.net使用DataGridView更新数据时出错Update 无法找到 TableMapping['Table'] 或 DataTable“Table”。
为什么会这样,求大神帮忙
Public Class Form1
Dim connstr As String = "Data Source=pc-20140831ptoa;Initial Catalog=student;Integrated Security=True"
Dim conn As New SqlConnection(connstr)
Dim da3 As SqlDataAdapter
Dim ds3 As DataSet
Public cb As SqlCommandBuilder '定义为全局变量
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim sql2 = "select* from 课程权重 where 教师编号=1001 "
Dim cmd2 As New SqlCommand(sql2, conn)
da3 = New SqlDataAdapter(sql2, conn)
ds3 = New DataSet()
da3.Fill(ds3, "课程权重")
DataGridView1.DataSource = ds3.Tables("课程权重")
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Try
If ds3.HasChanges Then
da3.Update(ds3.GetChanges)
DataGridView1.CurrentCell = DataGridView1.Rows(0).Cells(0)
MessageBox.Show("修改成功!")
Else
DataGridView1.CurrentCell = DataGridView1.Rows(0).Cells(0)
MessageBox.Show("无修改的内容!")
End If
' Catch ex As Exception
' MessageBox.Show("修改出错!")
' End Try
End Sub
为什么会说找不到数据表呢,我是定义的全局啊,为什么就没有传过来,急啊!求大神帮忙 展开
为什么会这样,求大神帮忙
Public Class Form1
Dim connstr As String = "Data Source=pc-20140831ptoa;Initial Catalog=student;Integrated Security=True"
Dim conn As New SqlConnection(connstr)
Dim da3 As SqlDataAdapter
Dim ds3 As DataSet
Public cb As SqlCommandBuilder '定义为全局变量
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim sql2 = "select* from 课程权重 where 教师编号=1001 "
Dim cmd2 As New SqlCommand(sql2, conn)
da3 = New SqlDataAdapter(sql2, conn)
ds3 = New DataSet()
da3.Fill(ds3, "课程权重")
DataGridView1.DataSource = ds3.Tables("课程权重")
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Try
If ds3.HasChanges Then
da3.Update(ds3.GetChanges)
DataGridView1.CurrentCell = DataGridView1.Rows(0).Cells(0)
MessageBox.Show("修改成功!")
Else
DataGridView1.CurrentCell = DataGridView1.Rows(0).Cells(0)
MessageBox.Show("无修改的内容!")
End If
' Catch ex As Exception
' MessageBox.Show("修改出错!")
' End Try
End Sub
为什么会说找不到数据表呢,我是定义的全局啊,为什么就没有传过来,急啊!求大神帮忙 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询