Page 1 of 1

Problem with "gbk and blob field"

Posted: Sat 28 Oct 2006 12:35
by vga
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?

Posted: Tue 31 Oct 2006 10:58
by Antaeus
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

Posted: Wed 01 Nov 2006 14:03
by vga
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

Posted: Wed 01 Nov 2006 15:15
by Antaeus
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.

Posted: Tue 07 Nov 2006 22:44
by vga
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.

Posted: Sat 11 Nov 2006 12:59
by vga
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

Posted: Mon 13 Nov 2006 14:48
by Antaeus
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.

Posted: Tue 14 Nov 2006 00:53
by vga
I have send the progran to evgeniyD*crlab*com

thanks a lot.

Posted: Tue 14 Nov 2006 13:33
by Antaeus
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 := ;

Posted: Wed 15 Nov 2006 02:02
by vga
I know. thanks.