SQLite: Getting "cannot convert type" error when loading image into Blob field

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

SQLite: Getting "cannot convert type" error when loading image into Blob field

Post by VadimShvarts » Wed 05 Mar 2014 07:25

UniDAC 5.2.7
Delphi XE5 Update2
SQLiteUniProvider

I ran the following code:

Code: Select all

program Project1;

{$APPTYPE CONSOLE}

uses SysUtils, Uni, SQLiteUniProvider, DB;

var
  UniConnection: TUniConnection;
  UniQuery: TUniQuery;
  BlobField: TBlobField;
begin
  UniConnection := TUniConnection.Create(nil);
  try
    UniConnection.ProviderName := 'SQLite';
    UniConnection.SpecificOptions.Values['SQLite.Direct'] := 'True';
    UniConnection.Database := ':memory:';
    UniConnection.Connect;
    UniConnection.ExecSQL('create table test (id integer, pic blob)');
    UniConnection.ExecSQL('Insert into test(id) values (1)');

    UniQuery := TUniQuery.Create(nil);
    try
      UniQuery.Connection := UniConnection;
      UniQuery.SQL.Text := 'Select * from test';
      UniQuery.Open;
      UniQuery.Edit;
      BlobField := UniQuery.FieldByName('Pic') as TBlobField;
      BlobField.LoadFromFile('d:\test.bmp');
      UniQuery.Post;
    finally
      UniQuery.Free;
    end;
  finally
    UniConnection.Free;
  end;
end.
I got the error "CANNOT CONVERT TYPE"

Error stack:
LiteClassesUni.BindBlob
...
UniQuery.Post

Same issue in LiteDAC was solved 26 Dec 2013

http://forums.devart.com/viewtopic.php?f=48&t=28564

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: SQLite: Getting "cannot convert type" error when loading image into Blob field

Post by AlexP » Wed 05 Mar 2014 12:21

hello,

This problem is fixed in the LiteClasses module. LiteClassesUni is a module similar to LiteClasses, therefore this fix was added to both LiteDAC and UniDAC. Please make sure there are no modules from the old UniDAC version.

VadimShvarts
Posts: 34
Joined: Mon 22 Dec 2008 09:03

Re: SQLite: Getting "cannot convert type" error when loading image into Blob field

Post by VadimShvarts » Wed 05 Mar 2014 12:30

AlexP wrote:hello,

This problem is fixed in the LiteClasses module. LiteClassesUni is a module similar to LiteClasses, therefore this fix was added to both LiteDAC and UniDAC. Please make sure there are no modules from the old UniDAC version.
LiteClassesUni have this error in last UNIDAC version 5.2.7

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: SQLite: Getting "cannot convert type" error when loading image into Blob field

Post by AlexP » Thu 06 Mar 2014 10:25

Sorry, this fix wasn't added to the current version. It will be available in the next build.

wangxiya
Posts: 4
Joined: Tue 10 Jul 2012 14:35

Re: SQLite: Getting "cannot convert type" error when loading image into Blob field

Post by wangxiya » Tue 18 Mar 2014 04:07

Please solve the problem, and release new version as soon as possible!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: SQLite: Getting "cannot convert type" error when loading image into Blob field

Post by AlexP » Fri 21 Mar 2014 14:10

We plan to release UniDAC within a month.

Post Reply