问题:
我看到两个例题,第一个例题绑定数据源到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;
//后面代码省略...
我看到两个例题,第一个例题绑定数据源到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;
//后面代码省略...
解决方案 »
- 图片上传 支持本地上传的 编辑器
- FormView1的FindControl方法
- ICallbackEventHandler实现AJAX后,提交页面的时候后台获取不到前台控件的值
- 字符串前后加一个"["
- 请教.net中可以分页的控件有哪些
- 图片上面怎么样放控件
- 为什么我用using System.Data.OracleCilent时,在Data后面没有OracleCilent???
- 如何在datagrid中改变同一列中各行的不同样式
- 高手指点-验证问题,好像是我Web.config事 没有调对!
- ajax如何传送大型表单的数据?
- gridview跨页传值
- .net 当中的datagrid问题!!!!!
这方法就知道后面参数是什么了
sda.Fill(ds,"order");表示把数据填充到ds,表名order
sda.Fill(ds);表示把从数据源中检索行填充到ds
sda.Fill(ds);表示把从数据源中检索行填充到ds orders是给表起的名字
本人也是新手,以上纯个人理解。
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.