,Update和Delete属性。
As I mentioned earlier, the SqlCommandBuilder has limitations. It works when you do a simple select statement on a single table. However, when you need a join of two or more tables or must do a stored procedure, it won''''t work. I''''ll describe a work-around for these scenarios in future lessons.
正如我先前所说,SqlCommandBuilder有限制性。它能在你对单独的表做简单的select语句的时候有效。然而,当需要连接两个以上的表或者必须执行一个存储过程的时候,它不会起作用。我将在以后的课程中描述这些场景的工作区。
Filling the DataSet
填充DataSet
Once you have a DataSet and SqlDataAdapter instances, you need to fill the DataSet. Here''''s how to do it, by using the Fill method of the SqlDataAdapter:
当具有一个DataSet和SqlDataAdapter实例以后,你需要填充数据集。下面是如何实现它,只要使用SqlDataAdapter的Fill方法:
daCustomers.Fill(dsCustomers, "Customers");
The Fill method, in the code above, takes two parameters: a DataSet and a table name. The DataSet must be instantiated before trying to fill it with data. The second parameter is the name of the table that will be created in the DataSet. You can name the table anything you want. Its purpose is so you can identify the table with a meaningful name later on. Typically, I''''ll give it the same name as the database table. However, if the SqlDataAdapter''''s select command contains a join, you''''ll need to find another meaningful name.
上面代码中的Fill方法具有两个参数: 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> [Web开发]ADO.NET读书笔记系列之------SqlDataAdapter对象
|