{"Update 无法找到 TableMapping['Table'] 或 DataTable“Table”错误!!!!!!!

jsjhj2008 2007-12-08 03:12:17
private void button1_Click(object sender, EventArgs e)
{
DataSet mydataset= dataset1.GetChanges();
if (mydataset!= null)
{
int rows = adapter1.Update(mydataset);"//运行到这步就出错了{"Update 无法找到 TableMapping['Table'] 或 DataTable“Table”错误!!!!!!!"

MessageBox.Show("数据库更新成功:" + rows.ToString() + "条", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
mydataset.AcceptChanges();
}
else
{
MessageBox.Show("数据库没有初始化", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
兄弟们帮我看下啊!!!!更新出错!
...全文
563 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zxcayumi 2009-03-10
  • 打赏
  • 举报
回复
应该检查一下DataTable的名称
DataTable tb = new DataTable();
tb.TableName = "";//这一句
lsj_zrp 2007-12-08
  • 打赏
  • 举报
回复
上面写错了
private void button1_Click(object sender, EventArgs e)
{
if (dataset1.HasChanges())
{
int rows = adapter1.Update(dataset1);"//运行到这步就出错了{"Update 无法找到 TableMapping['Table'] 或 DataTable“Table”错误!!!!!!!"
MessageBox.Show("数据库更新成功:" + rows.ToString() + "条", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
mydataset.AcceptChanges();
}
else
{
MessageBox.Show("数据库没有初始化", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);



}

另外你的SELECT * FROM yh ;"yh"表里必须要有主键
lsj_zrp 2007-12-08
  • 打赏
  • 举报
回复
感觉是DataSet mydataset= dataset1.GetChanges(); 这里的问题
没有必要重新定义一个DataSet;试试这样
private void button1_Click(object sender, EventArgs e)
{
if (dataset1.HasChanges())
{
int rows = adapter1.Update(dataset1);"//运行到这步就出错了{"Update 无法找到 TableMapping['Table'] 或 DataTable“Table”错误!!!!!!!"

MessageBox.Show("数据库更新成功:" + rows.ToString() + "条", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
mydataset.AcceptChanges();
}
else
{
MessageBox.Show("数据库没有初始化", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

另外你的SELECT * FROM yh ;"yh"表里必须要有主键

}
skyzero110 2007-12-08
  • 打赏
  • 举报
回复
你这个数据源 绑那里了? 之前 dataset1 如果用过一次了
在new一次
dataset1 =new dataset();
adapter1=new sqladapter();
adapter1.SelectCommand.CommandText = strsql;
adapter1.SelectCommand.Connection = sqlconnection1;
jsjhj2008 2007-12-08
  • 打赏
  • 举报
回复
我这个dataset1有数据源的啊!
string strsql = "SELECT * FROM yh";
adapter1.SelectCommand.CommandText = strsql;
adapter1.SelectCommand.Connection = sqlconnection1;
skyzero110 2007-12-08
  • 打赏
  • 举报
回复
根据他的错误提示,没有绑定数据源吧?
设断点 看看

110,552

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧