TAILIEUCHUNG - Executing Queries That Use COMPUTE BY

[ Team LiB ] Recipe Executing Queries That Use COMPUTE BY Problem The SQL Server .NET data provider does not support the COMPUTE BY clause but you want to execute a COMPUTE BY statement using . | Team LiB Recipe Executing Queries That Use COMPUTE BY Problem The SQL Server .NET data provider does not support the COMPUTE BY clause but you want to execute a COMPUTE BY statement using . Solution Use the COMPUTE BY statement from the Command object of the OLE DB .NET data provider. The sample code defines a COMPUTE BY statement and executes it using the ExecuteReader method of the OleDbCommand object. Multiple result sets are returned by the DataReader and then these are displayed. The C code is shown in Example 3-13. Example 3-13. File Namespaces variables and constants using System using using using . . . StringBuilder result new StringBuilder String sqlSelect select OrderlD ProductID Quantity FROM Order Details ORDER BY ProductID COMPUTE SUM quantity by ProductID OleDbConnection conn new OleDbConnection OleDb_Shape_ConnectString OleDbCommand cmd new OleDbCommand sqlSelect conn OleDbDataReader dr do Order tProduct tQuantity while 0 t 1 t 2 Get the sum. SUM t t 0 while Discussion The SQL Server .NET data provider does not support the COMPUTE BY clause but the OLE DB .NET data provider does. The results are returned as multiple pairs of result sets the first of which contains the selected details and the second containing the results of the aggregate functions specified the sum of the quantity ordered for the product in this example in the COMPUTE BY clause. This pattern is repeated for the remaining pairs of result sets. Microsoft states that the COMPUTE and COMPUTE BY clauses are provided in SQL Server and later versions for backward compatibility.

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.