tailieunhanh - Connecting to Access and Oracle Databases

Connecting to Access and Oracle Databases In this section you'll see examples of connecting to both an Access and an Oracle database. To interact with either of these databases in your program | Connecting to Access and Oracle Databases In this section you ll see examples of connecting to both an Access and an Oracle database. To interact with either of these databases in your program you use classes from the namespace. This namespace contains classes for use with databases that support object linking and embedding for databases OLE DB such as Access or Oracle. You ll learn more about the namespace in Chapter 5 Overview of the Classes. Connecting to an Access Database You connect to an Access database using an OleDbConnection object-rather than a SqlConnection object-with a connection string of the following format provider data source databaseFile where databaseFile is the directory and filename of your Access database. Notice that you specify the provider in the connection string which is set to . The following example creates a string named connectionString with the appropriate format to connect to the Access Northwind database stored in the file string connectionString provider data source F Program Files Microsoft Office Office Samples Note Notice the use of two backslash characters in the data source part of the connection string. The first backslash is used to specify that the second backslash is to be treated literally therefore is treated as in the connection string. You ll need to locate the file on your hard disk and set your connection string appropriately. Assuming the namespace has been imported the following example creates an OleDbConnection object passing connectionString set in the previous line of code to the constructor OleDbConnection myOleDbConnection new OleDbConnection connectionString Listing illustrates how to connect to the Northwind Access database using an OleDbConnection object and retrieve a row from the Customers table. Notice that you use an .

TÀI LIỆU LIÊN QUAN
10    127    1
6    150    1
7    127    1
5    125    1
6    127    1
6    115    1
6    122    1
6    174    1
7    122    1
5    97    1
crossorigin="anonymous">
Đã 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.