| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2575 人关注过本帖
标题:vb.net使用DataGridView更新数据时出错Update 无法找到 TableMapping['Tabl ...
取消只看楼主 加入收藏
新手啦
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-6-10
收藏
 问题点数:0 回复次数:1 
vb.net使用DataGridView更新数据时出错Update 无法找到 TableMapping['Table'] 或 DataTable“Table”。
使用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
为什么会说找不到数据表呢,我是定义的全局啊,为什么就没有传过来,急啊!求大神帮忙
2015-06-10 13:46
新手啦
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-6-10
收藏
得分:0 
要疯了一直找不到原因,第一次用写,还多都不懂求大神帮忙啊
2015-06-10 13:53
快速回复:vb.net使用DataGridView更新数据时出错Update 无法找到 TableMapping[ ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020641 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved