| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1659 人关注过本帖
标题:[求助!!]按Button键保存dataGrid中的数据。
只看楼主 加入收藏
kaka0368
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-4-23
收藏
 问题点数:0 回复次数:11 
[求助!!]按Button键保存dataGrid中的数据。
按Button键保存dataGrid中的数据如何实现?也就是在dataGrid中直接修改数据,然后按Button保存,代码怎么写?有人知道吗?各位大虾请帮帮忙!
搜索更多相关主题的帖子: Button键 dataGrid中 数据 保存 大虾 
2005-04-24 22:33
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
try
   {
    DataSet changedData=this.dataSet11.GetChanges();
    if(changedData!=null)
    {
     int changedRows=sqlDataAdapter1.Update(changedData);
     MessageBox.Show("数据库成功更新了"+changedRows+"条记录","成功",MessageBoxButtons.OK,MessageBoxIcon.Information);
     dataSet11.AcceptChanges();
    }
    else
    {
     MessageBox.Show("没有需要保存的记录","没有改变",MessageBoxButtons.OK,MessageBoxIcon.Information);
    }
   }
  
   catch(Exception ex)
   {
    MessageBox.Show("更新数据库时发生了错误:"+ex.Message,"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
    dataSet11.RejectChanges();
   }

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-26 10:48
kaka0368
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-4-23
收藏
得分:0 
谢谢你!小飞猪大虾!!

我是初学者。请多多照顾!
2005-04-29 08:31
kaka0368
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-4-23
收藏
得分:0 
哎呀,不对,刚刚还没有看清,这代码和我原本写的代码一样,我调试的时候还是不能实现,当插入一条记录或者删除一条记录,然后点击“保存”,就会跳出“更新数据库是发生了错误:更新无法找到TableMapping["Table"]或DataTable"Table"。”的“错误”对话框!这是为什么啊?我用的数据库是Access数据库。还望指教!!

我是初学者。请多多照顾!
2005-04-29 08:51
幻风幻云
Rank: 1
等 级:新手上路
帖 子:762
专家分:0
注 册:2005-1-14
收藏
得分:0 
你的。net版本多少?

2005-04-29 09:31
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
不是吧。我这行的。我这就是从我编的程序里复制来的
把Sql改成oleDb都不行吗
是不是你前面有什么东西没设好啊

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-29 10:34
幻风幻云
Rank: 1
等 级:新手上路
帖 子:762
专家分:0
注 册:2005-1-14
收藏
得分:0 
小飞猪是偶滴助手!

2005-04-29 10:48
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 
幻幻是偶滴老师

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-29 13:31
幻风幻云
Rank: 1
等 级:新手上路
帖 子:762
专家分:0
注 册:2005-1-14
收藏
得分:0 
老师不敢当

最多学长罢了

2005-04-29 13:43
yushengou
Rank: 1
等 级:新手上路
帖 子:401
专家分:0
注 册:2005-3-30
收藏
得分:0 

也懂谦虚啊

我是初学者,希望大家能多多帮助我 /bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://bbs./bbs/showimg.asp?BoardID=34&filename=2005-4/200542294030151.gif');}" onmousewheel="return imgzoom(this);" alt="" />
2005-04-29 13:47
快速回复:[求助!!]按Button键保存dataGrid中的数据。
数据加载中...
 
   



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

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