• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
熊猫86
博客园    首页    新随笔    联系   管理    订阅  订阅

DataSet图解


thisDataSet.Tables["Cutomers"].Rows[n]["CompanyName"]

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace DataContrast
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load( object sender, EventArgs e )
        {

            SqlConnection conn = new SqlConnection( "Data Source=zhengchenhan;Initial Catalog=zchtest;Integrated Security=True" );

            //conn.Open();

            //SqlCommand cmd = conn.CreateCommand();

            //cmd.CommandText = "select Name,Pwd from Users";

            //SqlDataReader DR = cmd.ExecuteReader();
            SqlDataAdapter adpter = new SqlDataAdapter( "select Name,Pwd from Users", conn );
          
            DataSet DS = new DataSet();

            adpter.Fill( DS, "Users" );//这里的 Users不是指数据库中的表名 ,是指DS中药创建的填充数据的DataTable对象名称
            foreach ( DataRow theRow in DS.Tables["Users"].Rows )
            {
                Response.Write( theRow["Name"] + "</br>" + theRow["Pwd"] );
            }
            conn.Close();
        }
           

        //    while(DR.Read())
        //    {
        //        Response.Write( DR["Name"] + "</br>" + DR["Pwd"] + "</br>" );
        //    }
        //    DR.Close();
        //    conn.Close();
        //}




       
    }
}

发芽网 © 2008 By 半瓶墨水 ( 发芽网开发日志 ) | Twitter: @realfun | 友情链接 | Powered By Django | Hosted on Bluehost
posted @ 2010-04-13 11:24  熊猫86  阅读(135)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3