tailieunhanh - Microsoft SQL Server 2005 Developer’s Guide- P33

Microsoft SQL Server 2005 Developer’s Guide- P33:SQL Server 2005 is a feature-rich release that provides a host of new tools and technologies for the database developer. This book is written to help database developers and DBAs become productive immediately with the new features and capabilities found in SQL Server 2005. | Chapter 8 Developing Database Applications with ADO 299 Private Sub BookMarkFind cn As _ rs As oBookMark As Variant With rs .CursorLocation adUseClient .Open Select from Order By SpecialOfferID cn End With Find Mountain Tire Sale and set a bookmark Description Mountain Tire Sale adSearchForward oBookMark Find Volume Discount over 60 display the remainder of the resultset Description Volume Discount over 60 adSearchBackward DisplayForwardGrid rs hflxResults End Sub In the beginning of the BookmarkFind subroutine you can see where instances of the ADO Connection and Recordset objects are passed into the subroutine. In addition a Variant variable named oBookMark is used to pass back the bookmark to be set inside this routine. Next a With statement is used to assign values to properties of the rs Recordset object. Using a value of adUseClient indicates the Recordset will be maintained on the client system rather than on the SQL Server system. Using a local cursor typically provides much better performance for processing small and medium result sets consisting of a few hundred records. Then the Open method is used along with a SQL select statement that retrieves all the rows and columns from the Sales. SpecialOffer table and orders them by SpecialOfferID. After the Open method has completed the rs Recordset object will be populated and the Find method can then be used to locate specific records within the Recordset. In this code listing the Find method is used twice. The first instance of the Find method is used to locate the first row in the Recordset where the Description column contains the value of Mountain Tire Sale. The first parameter of the Find method takes the search argument which uses the same type of search criteria used in a typical Where clause. The ADO Find method search criteria can use a single field name with one comparison operator and a literal value to use in the .

TỪ KHÓA LIÊN QUAN