Problem with "gbk and blob field"

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

Problem with "gbk and blob field"

Post by vga » Sat 28 Oct 2006 12:35

database: mydql 5.0
db access Compoents: mydac4.3

mysql default character set: gbk

when i post a picture to blob field of a table, a error occur. while set mydac connection character set to spsce, it works ok.

why?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 31 Oct 2006 10:58

Please supply us following information:
- Exact version of Delphi, C++ Builder or Kylix
- Exact version of MyDAC. You can see it in About sheet of TMyConnection Editor
- Exact version of MySQL server and MySQL client. You can see it in Info sheet of TMyConnection Editor
- Exact definition of the field used to store BLOBs

vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

Post by vga » Wed 01 Nov 2006 14:03

thanks.


Exact version of Delphi: 7.0 build 8.1
Exact version of MyDAC: 4.30.0.11 trial for delphi 7
Exact version of MySQL server and MySQL client :
MySQL server version: 5.0.22-community-nt
MySQL client version: Direct

- Exact definition of the field used to store BLOBs:
CREATE TABLE `b0001_pic` (
`Pic_Id` smallint(6) unsigned NOT NULL auto_increment,
`Pic_Image` longblob,
PRIMARY KEY (`Pic_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 01 Nov 2006 15:15

Try to test this issue with the last build of MyDAC (4.40.0.20). You can download it from our site. If the problem persists then send us (evgeniyD*crlab*com) a complete small sample to demonstrate it.

vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

Post by vga » Tue 07 Nov 2006 22:44

I store Image info in blob field , so, I modify the procedure:

procedure TData.WriteBlob(FieldNo: word; RecBuf: IntPtr; Position: longint;
Count: longint; Source: IntPtr);
var
Blob: TBlob;
S: string;
Ws: WideString;
Buf: IntPtr;
begin
Blob := TBlob(GetObject(FieldNo, RecBuf));

Blob.EnableRollback;
Blob.Write(Position, Count, Source); // add by vga

{ //delete by vga
if not Blob.FIsUnicode then
Blob.Write(Position, Count, Source)
else
begin
S := Marshal.PtrToStringAnsi(Source, Count);
Ws := S;
Buf := Marshal.StringToHGlobalUni(Ws);
try
Blob.Write(Position shl 1, Count shl 1, Buf);
finally
Marshal.FreeCoTaskMem(Buf);
end;
end;
} // delete

SetNull(FieldNo, RecBuf, False);
end;


thanks.

vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

Post by vga » Sat 11 Nov 2006 12:59

DM.SQLQuery_JobInfo.SQL.Text :=
'select * from `' + JobInfoTable + '` limit 1';
DM.SQLQuery_JobInfo.Active := True;

if DM.SQLQuery_JobInfo.IsEmpty then
DM.SQLQuery_JobInfo.Append
else
DM.SQLQuery_JobInfo.Edit;

TBlobField(DM.SQLQuery_JobInfo.FieldByName('Pic_Image')).LoadFromFile(edtSamplePicName.Text);

gExtName := ExtractFileExt(edtSamplePicName.Text);
DM.SQLQuery_JobInfo.FieldByName('ExtName').AsString := gExtName;

DM.SQLQuery_JobInfo.FieldByName('UseFirstPage').AsString := gFirstPage;

DM.SQLQuery_JobInfo.Post; // error occured here

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 13 Nov 2006 14:48

You have not specified if the problem is reproducible with the last build of MyDAC. If it does then send us a complete small sample to demonstrate it. Also specify if any changes of MySQL Server settings should be made.

vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

Post by vga » Tue 14 Nov 2006 00:53

I have send the progran to evgeniyD*crlab*com

thanks a lot.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 14 Nov 2006 13:33

Thank you for the sample. Your sample shows that the problem does not concern working with a BLOB field. As we can see, the UseUnicode option of the connection object is set to True. So try to use:

Code: Select all

 ParamByName('xxx').AsWideString := ;
instead of:

Code: Select all

ParamByName('xxx').AsString := ;

vga
Posts: 58
Joined: Sat 08 Jul 2006 12:04

Post by vga » Wed 15 Nov 2006 02:02

I know. thanks.

Post Reply