Microsoft SQL Server 2005 Developer’s Guide- P16

Microsoft SQL Server 2005 Developer’s Guide- P16:This book is the successor to the SQL Server 2000 Developer’s Guide, which was extremely successful thanks to all of the supportive SQL Server developers who bought that edition of the book. Our first thanks go to all of the people who encouraged us to write another book about Microsoft’s incredible new relational database server: 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 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
12    26    1    01-12-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.