Combining Data in Tables from Heterogeneous Data Sources

[ Team LiB ] Recipe Combining Data in Tables from Heterogeneous Data Sources Problem You want to create a report that is based on data from tables in more than one data source. Solution Use ad-hoc connector names in SQL statements. | Team LiB Recipe Combining Data in Tables from Heterogeneous Data Sources Problem You want to create a report that is based on data from tables in more than one data source. Solution Use ad-hoc connector names in SQL statements. The sample code retrieves data from both a SQL Server table and a Microsoft Access table to create a single result set. Specifically Northwind Order data is retrieved from SQL Server and Northwind Order Details data is retrieved from Access and joined to the Order information. The C code is shown in Example 3-6. Example 3-6. File Namespaces variables and constants using System using using using . . . Fill the table with data from SQL Server and MS Access. String sqlSelect SELECT FROM Orders o INNER JOIN OPENROWSET MsAccess_Database_Filename admin Order Details AS od ON ORDER BY SqlDataAdapter da new SqlDataAdapter sqlSelect Sql_ConnectString DataTable dt new DataTable dt Set up and bind a view with data from both tables. DataView dv false false false dv Discussion Microsoft SQL Server 2000 and later supports two methods to access data from heterogeneous data sources through OLE DB linked servers and ad hoc connector names. You can refer to linked servers in SQL statements using a four-part name comprised of the names of the linked server the catalog the schema within the catalog and data object. These names are separated with periods. If the data sources are going to be accessed frequently defining them as linked servers rather than through ad hoc connector names as shown in the sample will improve performance. For more information about using

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
Đã 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.