问题:
我看到两个例题,第一个例题绑定数据源到repeater控件就结束了。fill填充方法里只有ds这个参数,但是第二个例子为什么除了ds参数,还多了个order表名呢?
第二个例题是要在repeater控件上再加一个PageDataSource的控件,
他有这样一个操作,是不是就因为这行代码的原因,(pages.DataSource = ds.Tables["orders"].DefaultView;)
才在那个fill方法里多了个order的表名呢?
con.open();
string cmdtext = "select top8 shipname,shipaddress from orders";
SqlDataAdapter sda = new SqlDataApter(cmdtext,con);
DataSet ds = new DataSet();
sda.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();string cmdtext = "select shipname from orders";
SqlDataAdapter sda = new SqlDataApter(cmdtext,con);
DataSet ds = new DataSet();
sda.Fill(ds,"order"); //我就是这里不明白,为什么上面的fill方法里面只有一个ds,而这个fill方法里面还有一个order的表名呢?
PageDataSource pages = new PageDataSource();
pages.DataSource = ds.Tables["orders"].DefaultView;
//后面代码省略...

解决方案 »

  1.   

    你到vs 里的object browser里看下DataAdapter.fill(xxxxxxxxx)
    这方法就知道后面参数是什么了
      

  2.   

    sda.Fill(ds,"order");表示把表order填充到dssda.Fill(ds);表示把SqlDataAdapter填充到ds,默认ordersda.fill(ds,10,20,"tb") 就是把selectcomand返回的所有数据中从第10条开始,连续取20条填充到ds的tb表中 
      

  3.   

    orders只不过是给表起的名字罢了。
      

  4.   

    Fill 方法使用关联的 SelectCommand 属性所指定的 SELECT 语句从数据源中检索行.
    sda.Fill(ds,"order");表示把数据填充到ds,表名order 
    sda.Fill(ds);表示把从数据源中检索行填充到ds
      

  5.   

    sda.Fill(ds,"order");表示把selectcomand返回的所有数据填充到ds ,并起一个名字order
      

  6.   

    sda.Fill(ds,"order");表示把数据填充到ds,表名order 
    sda.Fill(ds);表示把从数据源中检索行填充到ds orders是给表起的名字
      

  7.   

    调用的时候也会有区别的,sda.Fill(ds,"order")调用的时候是ds.Tables["order"],比较不容易出错,sda.Fill(ds)调用的时候ds(序号)来调用的。这样子,你调用数据的时候比较容易出错。
    本人也是新手,以上纯个人理解。
      

  8.   

    public int Fill(System.Data.DataSet dataSet, string srcTable)
        Member of System.Data.Common.DbDataAdapterSummary:
    Adds or refreshes rows in the System.Data.DataSet to match those in the data source using the System.Data.DataSet and System.Data.DataTable names.Parameters:
    dataSet: A System.Data.DataSet to fill with records and, if necessary, schema.
    srcTable: The name of the source table to use for table mapping.Returns:
    The number of rows successfully added to or refreshed in the System.Data.DataSet. This does not include rows affected by statements that do not return rows.Exceptions:
    System.SystemException: The source table is invalid.