Page 1 of 1
Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 04:40
by Steven
Dear DevArt tech support.
I am using Delphi Xe2 with update 4 and latest version of LiteDAC trial.
I am using code directly from demo and trying to save image to a Blob field in my database.
The code appears to work until I either try to move off the record or use the post command then I get a "Cannot convert type' error.
When using LiteDAC (and a SQLite db that I have created using other tools) I can view images in the database, save them to file, clear them, etc. but just can't load images into the Blob field using LiteDAC.
Below is the code from the demo the only thing different is that in my database the field is named 'image' instead of 'Picture' (my code has been appropriately changed).
Code: Select all
procedure TPicturesFrame.btLoadClick(Sender: TObject);
var
BlobField: TBlobField;
FileName: string;
begin
if OpenPictureDialog.Execute then begin
if quPictures.State in [dsBrowse] then
quPictures.Edit;
BlobField := quPictures.FieldByName('Picture') as TBlobField;
FileName := OpenPictureDialog.FileName;
BlobField.LoadFromFile(FileName);
end;
end;
While the compiled demo works, I cannot load the demo project to debug this issue further because the full source for the project is not included with the demo (why?) nor can I load just the form in question because it references components used in the parent form.
If the missing files were included in the demo I probably wouldn't be stuck here bugging you for your assistance.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 05:44
by Steven
Ok, I've just finished hacking the Pictures form/pas files and built a project containing just one the one form - unfortunately it still has the same issue.
When I add a new image (one of the BMP images included with the demo) to the Blob field - as soon as I move the record and it tries to post the data I get the error message "Cannot convert type" which EurekaLog reports is occurring in the litedac160.bpl file.
Code: Select all
EurekaLog 6.1.04
Application:
-------------------------------------------------------
1.1 Start Date : Sun, 22 Dec 2013 22:03:34 -0800
1.2 Name/Description: PictureBlobTest.exe
1.3 Version Number : 0.3.0.0
1.4 Parameters :
1.5 Compilation Date: Sun, 22 Dec 2013 22:03:31 -0800
1.6 Up Time : 25 seconds
Exception:
-----------------------------------------------------
2.1 Date : Sun, 22 Dec 2013 22:03:59 -0800
2.2 Address : 03E1DAEE
2.3 Module Name : litedac160.bpl
2.4 Module Version: 2.1.4.0
2.5 Type : Exception
2.6 Message : Cannot convert type.
2.7 ID : D9DD
2.8 Count : 1
2.9 Status : New
2.10 Note :
User:
-------------------------------------------------------
3.1 ID : Steven
3.2 Name : Steven
3.3 Email :
3.4 Company :
3.5 Privileges: SeShutdownPrivilege - OFF
SeChangeNotifyPrivilege - ON
SeUndockPrivilege - OFF
SeIncreaseWorkingSetPrivilege - OFF
SeTimeZonePrivilege - OFF
Active Controls:
---------------------------------
4.1 Form Class : TfrmPictTest
4.2 Form Text : frmPictTest
4.3 Control Class: TDBGrid
4.4 Control Text :
Computer:
-------------------------------------------------------------------------------
5.1 Name : STEVEN-LT
5.2 Total Memory : 4094 Mb
5.3 Free Memory : 1556 Mb
5.4 Total Disk : 698.64 Gb
5.5 Free Disk : 37.53 Gb
5.6 System Up Time: 4 days, 13 hours, 25 minutes, 18 seconds
5.7 Processor : Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz
5.8 Display Mode : 1680 x 1050, 32 bit
5.9 Display DPI : 96
5.10 Video Card : NVIDIA GeForce 8600M GS (driver 9.18.13.623 - RAM 256 MB)
5.11 Printer : HP Photosmart 2600 series (driver 6.1.7601.17514)
Operating System:
--------------------------------------------
6.1 Type : Microsoft Windows 7 (64 bit)
6.2 Build # : 7601
6.3 Update : Service Pack 1
6.4 Language: English
6.5 Charset : 0
Call Stack Information:
-------------------------------------------------------------------------------------------------
|Address |Module |Unit |Class |Procedure/Method |Line |
-------------------------------------------------------------------------------------------------
|*Exception Thread: ID=8680; Priority=0; Class=; [Main] |
|-----------------------------------------------------------------------------------------------|
|03E1DAEE|litedac160.bpl | | | | |
|77A4012E|ntdll.dll | | |KiUserExceptionDispatcher| |
|5003DB50|rtl160.bpl |System.pas | |_RaiseExcept | |
|03E1DA70|litedac160.bpl |Liteclasses.pas |TSQLiteCommand|BindBlob | |
|03E1D504|litedac160.bpl |Liteclasses.pas |TSQLiteCommand|BindParams | |
|03E1CF11|litedac160.bpl |Liteclasses.pas |TSQLiteCommand|Execute | |
|76B262D0|USER32.dll | | |CallNextHookEx | |
|76B17252|USER32.dll | | |GetPropW | |
|76B17885|USER32.dll | | |DispatchMessageW | |
|76B1787B|USER32.dll | | |DispatchMessageW | |
|0086D2A5|PictureBlobTest.exe|PictureBlobTest.dpr| | |14[4]|
-------------------------------------------------------------------------------------------------
Modules Information:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|Handle |Name |Description |Version |Size |Modified |Path |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|00400000|PictureBlobTest.exe | |0.3.0.0 |16639644|2013-12-22 22:03:30|F:\Projects\MMJ\trunk\Sandbox |
|03DA0000|litedac160.bpl | |2.1.4.0 |639488 |2013-09-26 10:30:02|C:\Windows\system32 |
I cut the error report short because it was too long too post, be happy to send it to you if you need it.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 08:41
by AlexP
Hello,
We cannot reproduce the problem on the latest LiteDAC version and XE2. Please run the following code, and let us know the result.
Code: Select all
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils, LiteAccess, DB;
var
LiteConnection: TLiteConnection;
LiteQuery: TLiteQuery;
BlobField: TBlobField;
begin
LiteConnection := TLiteConnection.Create(nil);
try
LiteConnection.Database := ':memory:';
LiteConnection.Connect;
LiteConnection.ExecSQL('create table test (id integer, pic blob)');
LiteConnection.ExecSQL('Insert into test(id) values (1)');
LiteQuery := TLiteQuery.Create(nil);
try
LiteQuery.Connection := LiteConnection;
LiteQuery.SQL.Text := 'Select * from test';
LiteQuery.Open;
LiteQuery.Edit;
BlobField := LiteQuery.FieldByName('Pic') as TBlobField;
BlobField.LoadFromFile('d:\test.bmp');
LiteQuery.Post;
finally
LiteQuery.Free;
end;
finally
LiteConnection.Free;
end;
end.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 09:27
by Steven
I get the same "CANNOT CONVERT TYPE" error
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 10:25
by AlexP
Hello,
Please specify the used version of the SQLite3 library.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 10:51
by Steven
Hi,
SQLite library version 3.8.2 for 32-bit.
I reinstalled it Sunday morning when I ran into this issue.
Not sure what version I had before but the sqlite.dll was dated 9/10/2012.
BTW - I just doubled checked with a process viewer to make sure that the project wasn't loading some other version of SQLite in the file path. It is using the latest version.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 14:18
by AlexP
Hello,
Thank you for the information. We have reproduced and fixed the problem. This fix will be included to the next version.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Mon 23 Dec 2013 16:43
by Steven
Anything I can do in the meantime?
For example use an older version of SQLite?
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Tue 24 Dec 2013 11:49
by AlexP
Hello,
The new LiteDAC version including these fixes will be available this week already.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Tue 24 Dec 2013 11:57
by Steven
Cool, I'll keep an eye out for it.
thanks
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Thu 26 Dec 2013 09:49
by AlexP
Hello,
The new LiteDAC version is already available at our website for download now
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Thu 02 Jan 2014 08:08
by Steven
It is fixed in new version, thanks.
Re: Getting "cannot convert type" error when loading image into Blob field
Posted: Thu 02 Jan 2014 10:50
by AlexP
Hello,
Glad to see that the problem was solved. If you have any other questions, feel free to contact us.