| SqlDataAdapter属性或者通过SqlCommandBuilder.在这节课,我将介绍使用SqlCommandBuilder的简单方式。在接下来的课程中,我将介绍如何使用SqlDataAdapter属性,它将需要更多的工作但是会带来比SqlCommandBuilder更大的能力。下面是如何使用SqlCommandBuilder在SqlDataAdapter中添加命令:
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daCustomers);
Notice in the code above that the SqlCommandBuilder is instantiated with a single constructor parameter of the SqlDataAdapter, daCustomers, instance. This tells the SqlCommandBuilder what SqlDataAdapter to add commands to. The SqlCommandBuilder will read the SQL select statement (specified when the SqlDataAdapter was instantiated), infer the insert, update, and delete commands, and assign the new commands to the Insert, Update, and Delete properties of the SqlDataAdapter, respectively.
注意上面的代码中SqlCommandBuilder是使用一个SqlDataAdapter对象daCustomers作为参数的构造函数实例化的。这说明SqlCommandBuilder对哪一个SalDataAdapter添加命令。SqlCommandBuilder将读取SQL的select语句(在SqlDataAdapter被实例化的时候指明),推断inser,update和delete命令,并将新的命令分别赋值给SqlDataAdapter的Insert 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> |