C ++ Builder/Delphi access the Blob field of Oracle through ADO

Source: Internet
Author: User
Today, the Report Group reported an error when reading the Blob field of Oracle using ADO in CB5, so I tried it. The error message is "unsupported data type ".
I tried Delphi7 again.
I think the BCB/Delphi ADO is encapsulated. Is there a problem with encapsulation?
So I ran to VB and wrote a Demo, and it succeeded ~ It seems that it is encapsulation.
It seems that you only have to use OLE to directly manipulate ADO, write a code segment, and try again.
The BCB code is as follows: 1 void _ fastcall TForm1: Button1Click (TObject * Sender)
2 {
3 const AnsiString SQL = "SELECT * FROM Table WHERE ROWNUM <= 1 ";
4
5 Variant Conn;
6 Variant ResultSet;
7 Variant ResultField;
8 Variant Size, Value;
9
10 Conn = Variant: CreateObject ("adodb. connection ");
11 Conn. OlePropertySet ("Provider", "OraOLEDB. Oracle ");
12 Conn. OleFunction ("Open", "Database", "UserName", "Password ");
13
14 ResultSet = Variant: CreateObject ("adodb. recordset ");
15 ResultSet. OleFunction ("Open", SQL, Conn, 0, 1 );
16 ResultField = ResultSet. OlePropertyGet ("Fields", "FieldNameOrIndex ");
17 Size = ResultField. OlePropertyGet ("ActualSize ");
18 Value = ResultField. OleFunction ("GetChunk", Size );
19
20 void * Data = NULL;
21 SafeArrayAccessData (Value. parray, & Data );
22 try
23 {
24 TFileStream * Stream = new TFileStream ("C: \ blob.txt", fmCreate );
25 try
26 {
27 Stream-> Write (Data, Size );
28} _ finally {
29 delete Stream;
30}
31} _ finally {
32 SafeArrayUnaccessData (Value. parray );
33}
34}
Related Article

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.