| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 554 人关注过本帖
标题:使用datagrid更新信息出错
只看楼主 加入收藏
weilight2008
Rank: 1
等 级:新手上路
帖 子:111
专家分:4
注 册:2005-10-5
结帖率:50%
收藏
 问题点数:0 回复次数:2 
使用datagrid更新信息出错
我用datagrid修改信息使用了以下代码,可是点击提交之后,出现错误。
代码为:
this.oleDbDataAdapter1.SelectCommand.CommandText = "select * from admin ";
this.oleDbDataAdapter1.SelectCommand.Connection = this.oleDbConnection2;
System.Data.OleDb.OleDbCommandBuilder mybuilder = new System.Data.OleDb.OleDbCommandBuilder(this.oleDbDataAdapter1);
this.oleDbDataAdapter1.UpdateCommand = mybuilder.GetUpdateCommand();
this.oleDbDataAdapter1.UpdateCommand.Connection = this.oleDbConnection2;
this.oleDbDataAdapter1.DeleteCommand = mybuilder.GetDeleteCommand();
this.oleDbDataAdapter1.DeleteCommand.Connection = this.oleDbConnection2;
this.oleDbDataAdapter1.InsertCommand = mybuilder.GetInsertCommand();
this.oleDbDataAdapter1.InsertCommand = mybuilder.GetInsertCommand();
try
{
DialogResult result1;
result1=MessageBox.Show("您确定要修改此项内容吗?","系统提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
if(result1==DialogResult.OK)
{
this.oleDbDataAdapter1.Update(this.ds1,"admin");
MessageBox.Show("修改成功","系统提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
}
return;
}
catch(Exception ee)
{
MessageBox.Show(ee.Message);
}
错误提示为:update 无法找到Tablemapping['admin']或datatable"admin"
其中“admin”为所要操作的表
搜索更多相关主题的帖子: datagrid 
2006-03-23 17:02
ytyt654
Rank: 2
等 级:新手上路
威 望:4
帖 子:195
专家分:0
注 册:2006-2-13
收藏
得分:0 
try
   {
    DialogResult result1;
    result1=MessageBox.Show("您确定要修改此项内容吗?","系统提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
    if(result1==DialogResult.OK)
    {

MessageBox.Show(this.ds1.Tables.Contains("admin").ToString());

     this.oleDbDataAdapter1.Update(this.ds1,"admin");
     MessageBox.Show("修改成功","系统提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
    }
    return;
   }
   catch(Exception ee)
   {
    MessageBox.Show(ee.Message);
   }


检测一下

[此贴子已经被作者于2006-3-28 15:46:24编辑过]


2006-03-23 17:27
weilight2008
Rank: 1
等 级:新手上路
帖 子:111
专家分:4
注 册:2005-10-5
收藏
得分:0 
还是出现相同的错误提示阿

生活不相信眼泪,勇敢去拼。
2006-03-28 15:25
快速回复:使用datagrid更新信息出错
数据加载中...
 
   



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

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