标题:C#链接数据库直接在datagridview里面修改数据
取消只看楼主
hxy453089687
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-9-18
结帖率:0
 问题点数:0 回复次数:0 
C#链接数据库直接在datagridview里面修改数据
我的连接数据库代码是:
SqlConnection conn = new SqlConnection(@"Data Source=SAMSUNG-PC;Initial Catalog=jsflxt;Integrated Security=True");
            try
            {
                conn.Open();
            }
            catch (Exception e)
            {

            }
            return conn;
        }
        public void data()
        {
            SqlConnection conn = OpenCon();
            SqlCommand cmd = new SqlCommand();
             = "select * from jsxx";
            cmd.Connection = conn;
            SqlDataAdapter s = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            s.Fill(ds);
            this.dataGridView1.DataSource = ds.Tables[0];
        }
求写代码!
搜索更多相关主题的帖子: 数据库 连接数据库 public return 
2011-10-25 19:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-353413-1-1.html




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

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