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

Uploading Images to Oracle Database Using BLOB - Nó rất đơn giản để tải lên thông tin BLOB vào cơ sở dữ liệu Oracle. Tất cả chúng ta cần phải làm được đọc toàn bộ tập tin (trong các hình thức byte) và sử dụng OracleParameter cùng với OracleCommand để tải nó lên. | Chapter 6 The following is an illustration of a sample form designed to work with BLOB images 149 Dealing with Large Objects LOBs The following is an illustration of a sample form designed to work with BLOB documents Uploading Images to Oracle Database Using BLOB It is very simple to upload BLOB information into Oracle database. All we need to do is read the entire file in the form of bytes and use Oracleparameter together with OracleCommand to upload it. 150 Chapter 6 The following code uploads an image into the EmpImages table Private Sub btnAdd_Click ByVal sender As ByVal e As Handles If 0 Then No file chosen Exit Sub End If Now read the entire file into a string Dim contents As Byte _ create connection to db Dim cn As New OracleConnection Data Source xe _ User Id scott Password tiger Try create command object Dim sb As New INSERT INTO EmpImages empno image VALUES 1 2 Dim cmd As New OracleCommand With cmd .CommandText define parameters Dim p_empno As New OracleParameter 1 _ Dim p_img As New OracleParameter 2 _ contents . p_empno . p_img proceed with execution .Connection cn . .ExecuteNonQuery . .Dispose End With 151

TỪ KHÓA LIÊN QUAN