The code above creates a new SqlDataAdapter, daCustomers. The SQL select statement specifies what data will be read into a DataSet. The connection object, conn, should have already been instantiated, but not opened. It is the SqlDataAdapter''''s responsibility to open and close the connection during Fill and Update method calls.
上面的代码创建了一个新的SqlDataAdapter对象daCustomers,SQL的select语句指明了将哪些数据读入数据集。连接对象conn应该已经被实例化,但不用打开。这是由SqlDataAdapter在调用Fill和Update方法的时候负责打开和关闭连接的。
As indicated earlier, the SqlDataAdapter contains all of the commands necessary to interact with the data source. The code showed how to specify the select statment, but didn''''t show the insert, update, and delete statements. These are added to the SqlDataAdapter after it is instantiated.
正如早先指明的,SqlDataAdapter包含所有必需的与数据源交互的命令。代码显示了如何指定select语句,但是并没有显示insert,update和delete语句。这些在初始化以后添加到SqlDataAdapter中。
There are two ways to add insert, update, and delete commands: via SqlDataAdapter properties or with a SqlCommandBuilder. In this lesson, I''''m going to show you the easy way of doing it with the SqlCommandBuilder. In a later lesson, I''''ll show you how to use the SqlDataAdapter properties, which takes more work but will give you more capabilities than what the SqlCommandBuilder does. Here''''s how to add commands to the SqlDataAdapter with the SqlCommandBuilder:
这里有两种方式添加insert,update和delete命令:通过 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> [Web开发]ADO.NET读书笔记系列之------SqlDataAdapter对象
|