ODP .NET Developer's Guide oracle database 10g development with visual studio 2005 phần 3

Filling a DataTable Using OracleDataReader - Cho đến nay, chúng tôi đã được làm đầy các bảng dữ liệu bằng cách sử dụng OracleDataAdapter. cho chúng ta sự linh hoạt để điền vào một bảng dữ liệu sử dụng OracleDataReader là tốt. Các mã sau đây cung cấp cho bạn các chi tiết của tất cả các nhân viên có sẵn trong bảng EMP bằng cách điền vào một bảng dữ liệu bằng cách sử dụng một OracleDataReader:. | Chapter 3 Filling a DataTable Using OracleDataReader So far we have been filling data tables using OracleDataAdapter. gives us the flexibility to fill a data table using oracleDataReader as well. The following code gives you the details of all employees available in the emp table by filling a data table using an OracleDataReader Dim cn As New OracleConnection Data Source xe _ User Id scott Password tiger Try Dim SQL As String Dim dt As New DataTable build the SELECT statement SQL SELECT empno ename job mgr hiredate sal comm deptno FROM emp create command object to work with SELECT Dim cmd As New OracleCommand SQL cn open the connection get the DataReader object from command object Dim rdr As OracleDataReader _ check if it has any rows If Then simply bind datatable to grid rdr dt Else display message if no rows found Not found End If Catch ex As Exception display if any error occurs Error close the connection if it is still open If Then End If End Try Once the OracleConnection and OracleDataReader are created we need to create and fill a DataTable object using OracleDataReader itself. The following is the statement that creates a DataTable object Dim dt As New DataTable 51 Retrieving Data from Oracle Using To fill the above DataTable object with respect to OracleDataReader we can directly use the Load method of DataTable which accepts a DataReader object and the type of LoadOption. The following statement loads the content of an OracleDataReader into a DataTable object with a LoadOption as OverwriteChanges overwrites all the modifications that are available as part of the DataTable object rdr Retrieving a Single Row of Information Using

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
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.