转至繁体中文版     | 网站首页 | 文章中心 | 下载中心 | 图片中心 | 笑话频道 | 教程频道 | 会员中心 | 雁过留声 | 
最新公告:     "MinTao学以致用网"欢迎您的光临,你的支持便是我们的动力,欢迎广大网友和各界人士亲临指导,你们的一个小小的建议便是我们发展的开路石!  [MinTao  2007年9月5日]        
您现在的位置: MinTao学以致用网 >> 文章中心 >> 电子课堂 >> 数据库 >> Sql Server >> 文章正文
专题栏目
更多内容
最新推荐 更多内容
相关文章
SqlDataAdapter中Fill方
更多内容
SqlDataAdapter中的Fill方法(2)         
SqlDataAdapter中的Fill方法(2)
作者:thinkingforever 文章来源:不详 点击数: 更新时间:2007-11-14 12:03:51
nbsp;              {
                        return;
                  }
            }
            if (this.schemaTable == null)
            {
                  this.SetupSchemaWithoutKeyInfo(action1, action2, gettingData, parentChapterColumn, parentChapterValue);
            }
            else
            {
                  this.SetupSchemaWithKeyInfo(action1, action2, gettingData, parentChapterColumn, parentChapterValue);
            }
      }
}
 //FillLoadDataRowChunk
private int FillLoadDataRowChunk(SchemaMapping mapping, int startRecord, int maxRecords)
{
      IDataReader reader1 = mapping.DataReader;
      while (0 < startRecord)       //把DataReader调整到读startRecord记录的位置
      {                             //如果DataReader的总的记录数小于startRecord,就返回0
            if (!reader1.Read())    //其实在这里也可以看出要在DataReader中定位,只有去边历DataReader
            {                       //到这里我们也可以明白fill方法其实也是用DataReader一条条读出来的
                  return 0;
            }
            startRecord--;
      }
      int num1 = 0;
      if (0 >= maxRecords)
      {
            goto Label_0062;
      }
      bool flag1 = base.AcceptChangesDuringFill;//指示在Fill操作过程中,在将 AcceptChanges 添加到 DataTable 之后是否针对 DataRow 调用它。可以在msdn中的DataAdapter 类中查看
      goto Label_0054;
Label_002B:
      try
      {
            mapping.LoadDataRow(this.hasFillErrorHandler, flag1);//装载数据
            num1++;
      }
      catch (Exception exception1)
      {
            this.FillErrorHandler(exception1, mapping.DataTable, mapping.DataValues);
      }
Label_0054:
      if (num1 >= maxRecords)//如果载入的记录数已经满足条件,就退出,否则继续
      {
            goto Label_006A;
      }
      if (reader1.Read())//继续读取数据
      {
            goto Label_002B;
      }
      goto Label_006A;
Label_0062:
      num1 = this.FillLoadDataRow(mapping);
Label_006A:
      return num1;
}
到这里fill方法大概就完了,其实看来fill方法就是首先创建映射,然后在用datareader把数据填充进来.其中我忽略了好多东西比如它的异常处理,还有好多细节,请各位朋友多多指教,在这里列出来也是和各位朋友探讨。

上一页  [1] [2] [3] [4] 

文章录入:mintao    责任编辑:mintao 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007 MinTao学以致用网(www.mintao.net) Inc All Rights Reserved.
    QQ:543098146有事请Q我! QQ:261561092有事请Q我 QQ:179647303有事请Q我 MSN:min906@126.com
    站长:MinTao 信息产业部ICP备案号:鄂ICP备07500065号

    学以致用是我们学习者的至高境界和不懈追求,[MinTao学以致用网]与大家共同学习,共同进步……
    信息产业部备案
    *鄂ICP备07500065号