| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 466 人关注过本帖
标题:c# 修改错误
取消只看楼主 加入收藏
hybshanghai
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2014-7-13
结帖率:0
收藏
 问题点数:0 回复次数:0 
c# 修改错误
private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                int a = this.dataGrid1.CurrentCell.RowNumber;
                string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\c#\\book.mdb";
                OleDbConnection myConn = new OleDbConnection(strCon);
                myConn.Open();
                DataSet myDataSet = new DataSet();
                OleDbCommand command = new OleDbCommand("SELECT * FROM book order by 编号 ", myConn);
                OleDbDataAdapter ads = new OleDbDataAdapter(command);
                ads.Fill(myDataSet);
                string strCom = "UPDATE book set 书名='" + myDataSet.Tables["book"].Rows[a][1] + "',作者='" + myDataSet.Tables["book"].Rows[a][2] + "',价格=" + myDataSet.Tables["book"].Rows[a][3] + ",书架号=" + myDataSet.Tables["book"].Rows[a][4] + " where 编号=" + myDataSet.Tables["book"].Rows[a][0] +"";
                OleDbCommand inst = new OleDbCommand(strCom, myConn);
                inst.ExecuteNonQuery();
                OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT *FROM book order by 编号", myConn);
                myDataSet.Clear();
                myCommand.Fill(myDataSet, "book");
                this.dataGrid1.DataSource = myDataSet.Tables["book"];
                myConn.Close();
            }
            catch (Exception x)
            {
                MessageBox.Show("错误" + x.ToString(), "error"
图片附件: 游客没有浏览图片的权限,请 登录注册
);
            }
        }
搜索更多相关主题的帖子: command private 
2014-07-14 09:57
快速回复:c# 修改错误
数据加载中...
 
   



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

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