Read the Blob field in Oracle to generate the corresponding file

Source: Internet
Author: User

Read the Blob field of WMF and generate the wmf file.
/// <Summary>

/// Read the WMF field and generate a temporary WMF File

/// </Summary>

Private void ReadWMFBlobField ()

{

OracleConnection _ connection = new OracleConnection (m_connectionString );

Try

{

_ Connection. Open ();

 

OracleCommand _ selectCommand = _ connection. CreateCommand ();

OracleTransaction _ transaction = _ selectCommand. Connection. BeginTransaction ();

_ SelectCommand. Transaction = _ transaction;

 

String _ selectSQL = "Select WMF from hSUSEr. ZDT where ZDNO = '"

+ M_zoneNo + "'";

_ SelectCommand. CommandText = _ selectSQL;

 

OracleDataReader _ dataReader = _ selectCommand. ExecuteReader ();

If (_ dataReader. Read () = true)

{

Required lelob _ required lelob = _ dataReader. get1_lelob (0 );

Long _ byteCount = _ effeclelob. Length;

_ DataReader. Close ();

 

If (File. Exists (m_wmfFileName) = true)

{

File. Delete (m_wmfFileName );

}

 

FileStream _ fileStream = File. Open (m_wmfFileName, FileMode. OpenOrCreate );

Int _length = 30485760;

Byte [] _ buffer = new byte [_ length];

Int I = _ effeclelob. Read (_ buffer, 0, _ length );

While (I> 0)

{

_ FileStream. Write (_ buffer, 0, I );

I = _ effeclelob. Read (_ buffer, 0, _ length );

}

 

_ FileStream. Close ();

_ Canclelob. Close ();

_ SelectCommand. Parameters. Clear ();

 

_ Transaction. Commit ();

}

Else

{

MessageBoxEx. Show ("no matching records found! "," Prompt ", MessageBoxButtons. OK, MessageBoxIcon. Information );

}

}

Catch (Exception ex)

{

MessageBoxEx. Show (ex. Message, "Error", MessageBoxButtons. OK, MessageBoxIcon. Error );

}

}

Read the Blob field of DWG and generate the DWG file.
/// <Summary>

/// Read the DWG field and generate the DWG File

/// </Summary>

Private void ReadDWGBlobField ()

{

OracleConnection _ connection = new OracleConnection (m_connectionString );

 

Try

{

_ Connection. Open ();

 

OracleCommand _ selectCommand = _ connection. CreateCommand ();

OracleTransaction _ transaction = _ selectCommand. Connection. BeginTransaction ();

_ SelectCommand. Transaction = _ transaction;

 

String _ selectSQL = "Select DWG from hsuser. ZDT where ZDNO = '"

+ M_zoneNo + "'";

 

_ SelectCommand. CommandText = _ selectSQL;

 

OracleDataReader _ dataReader = _ selectCommand. ExecuteReader ();

 

If (_ dataReader. Read () = true)

{

Required lelob _ required lelob = _ dataReader. get1_lelob (0 );

Long _ byteCount = _ effeclelob. Length;

_ DataReader. Close ();

 

If (File. Exists (m_dwgFileName) = true)

{

File. Delete (m_dwgFileName );

}

 

FileStream _ fileStream = File. Open (m_dwgFileName, FileMode. OpenOrCreate );

 

Int _length = 30485760;

Byte [] _ buffer = new byte [_ length];

Int I;

While (I = _ effeclelob. Read (_ buffer, 0, _ length)> 0)

{

_ FileStream. Write (_ buffer, 0, I );

}

 

_ FileStream. Close ();

_ Canclelob. Clone ();

_ SelectCommand. Parameters. Clear ();

 

_ Transaction. Commit ();

}

Else

{

MessageBoxEx. Show ("no matching records found! "," Prompt ",

MessageBoxButtons. OK, MessageBoxIcon. Information );

}

}

 

Catch (Exception ex)

{

MessageBoxEx. Show (ex. Message, "warning", MessageBoxButtons. OK, MessageBoxIcon. Error );

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.