Page 1 of 1

C++, MySQL and BLOB field

Posted: Wed 20 Apr 2011 12:34
by BoyarskiyA
Greetings.
I had a difficulty at what loading or a file in BLOB field MySQL 5.1 package of components MyDAC
Here a code of loading of a file from BLOB fields and preservation on a hard disk of the client
Works normally. A code:

Code: Select all

TMemoryStream *M1 = new TMemoryStream(); 
 TStream *B1 = MyTable1->CreateBlobStream(MyTable1->FieldByName("blob"),bmRead); 
 M1->CopyFrom(B1,B1->Size); 
 M1->SaveToFile("C:\Image.jpg"); 
 delete B1; 
 delete M1;
And here with loading on the Server a problem the Code:

Code: Select all

MyTable1->Edit(); 
 TMemoryStream *M = new TMemoryStream(); 
 M->LoadFromFile("C:\ABOUT.rar"); 
 TStream *B = MyTable1->CreateBlobStream(MyTable1->FieldByName("blob"),bmWrite); 
 B->CopyFrom(M,M->Size); 
 delete B; 
 MyTable1->Post(); 
 delete M;
Or so: the Code:

Code: Select all

TBlobField *Fields; 
 MyQuery1->Insert(); 
 (MyQuery1->FieldByName("blob"),Fields)->LoadFromFile("C:\Image.jpg"); 
 MyQuery1->Post();
Error code:
http://www.imageup.ru/img177/bezymyannyjj635947.jpg

Posted: Wed 20 Apr 2011 15:01
by AndreyZ
Hello,

Please try composing a complete small sample to demonstrate the problem and send it to andreyz*devart*com, including a script to create a table. Also, please specify the following:
- your Windows codepage;
- your database charset.

Posted: Thu 21 Apr 2011 10:33
by BoyarskiyA
Here the reference to files of the table and a file of configuration MySQL. I use MySQL Server 5.1, Embarcadero RAD Studio 2010. Windows XP SP3 and Windows 7.
http://www.depositfiles.com/files/9kkhe6jc8

Posted: Thu 21 Apr 2011 14:51
by AndreyZ
We have reproduced the problem and the investigation of the problem is in progress. As soon as we solve the problem we will let you khow.

Posted: Fri 22 Apr 2011 14:34
by AndreyZ
The point is that "BLOB" is a reserved word in MySQL. To solve the problem, you should set the TMyQuery->Options->QuoteNames option to True.