DataSet离线数据集

//声明数据库连接字符串变量 

岑溪网站建设公司成都创新互联,岑溪网站设计制作,有大型网站制作公司丰富经验。已为岑溪1000多家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的岑溪做网站的公司定做!

string strconn = ConfigurationManager.ConnectionStrings["dbstrConn"].ConnectionString;

            
            using (SqlConnection conn = new SqlConnection(strconn)) 
            {   
                //打开连接
                conn.Open();
                //创建命令
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    //sql语句
                    cmd.CommandText = "select * from T_user";
                    SqlDataAdapter adpter = new SqlDataAdapter(cmd);
                    DataSet ds= new DataSet();
                    //填充数据集
                    adpter.Fill(ds);
                    //创建数据表
                    DataTable table= ds.Tables[0];
                    DataRowCollection rows = table.Rows;
                    //遍历数据表的每行
                    for (int i = 0; i < rows.Count; i++)
                    {
                        DataRow row = rows[i];
                        //获取列内容
                        string name=(string)row["name"];
                        MessageBox.Show(name);
                    }
               
                }
            }

网站题目:DataSet离线数据集
文章源于:http://csdahua.cn/article/jededc.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流