Page 1 of 1

Access ole field can not fetch correct, why?

Posted: Sat 03 Jul 2010 04:13
by c123321
i do not know how can i upload file, so i paste code here
1: first; create an access mdb file and a table sys_report
has two field id,(string) , reportdata(ole object)

write this code:

procedure TForm1.Button1Click(Sender: TObject);
var
filename:String;
begin
self.ADOQuery1.ConnectionString := Format('Provider=Microsoft.Jet.OLEDB.4.0; Data Source=%s; User Id=admin; Password=',[ExtractFilePath(Application.ExeName) + 'jzxxsjx.mdb']);
Self.ADOQuery1.Close;
Self.ADOQuery1.SQL.Clear;
Self.ADOQuery1.SQL.Add('Select * from SYS_REPORT where id=''60bcde8c-fc5c-4d64-bccf-1af919adb485''');
Self.ADOQuery1.Open;

filename := 'c:\aaa.doc';
TBlobField(Self.ADOQuery1.FieldByName('reportData')).SaveToFile(filename);
ShellExecute(0,PAnsiChar('open'),PAnsiChar(filename),nil,nil,1);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
coner : TUniConnection;
Gqry : TUniQuery;
filename:String;
begin
coner := TUniConnection.Create(Self); ;
Gqry := TUniQuery.Create(Self);
coner.ProviderName :='ACCESS';
coner.database := ExtractFilePath(Application.ExeName) + 'jzxxsjx.mdb';
coner.Connect;
Gqry.Connection := coner;

with Gqry do
begin
Close;
sql.Clear;
sql.Add('Select * from SYS_REPORT where id=''60bcde8c-fc5c-4d64-bccf-1af919adb485''');
open;
filename := 'c:\aaa_DAC.doc';
TBlobField(FieldByName('reportData')).SaveToFile(filename);
ShellExecute(0,PAnsiChar('open'),PAnsiChar(filename),nil,nil,1);
end;
end;



this demo show the same access ole object field,

the ado query can get fine data but
the unidac can not get fine data

why? the saved data is the same size but content is not the same


delphi7+ UNIDAC3.08


quickly ,, the program must finished next week; thanks [/url][/list]

Posted: Mon 05 Jul 2010 12:23
by bork
Hello

Similar bug was fixed in the UniDAC 3.00.0.9 version. To resolve your issue you should download the latest version of UniDAC from our site.

i had send demo project, the error had same

Posted: Wed 07 Jul 2010 05:22
by c123321
i had send demo project to

http://www.devart.com/company/contact.html


wait for result

Posted: Wed 07 Jul 2010 10:25
by bork
Hello

I got your sample. The cause of this problem is that UniDAC with Access data provider and ADO connection uses different ODBC drivers for Access database. The content of the saved file fully depends on the ODBC driver that you are using.

To resolve this issue you should set the ODBC data provider instead of Access data provider for TUniConnection. And for selected ODBC data provider you should select the same Access ODBC driver that is used by ADO connection. There are three Access ODBC drivers installed on my computer and all of them save file with different content. I tried all tree drivers one by one and found a driver that returned the same result as ADO connection.

Posted: Wed 07 Jul 2010 16:41
by c123321
as you said,

how can i know which odbc driver the ado used,

how can i publish a easy use and common software product?

write an example is very good

Posted: Thu 08 Jul 2010 11:18
by bork
Please create a new empty application and try to execute the following code:

Code: Select all

var
  file_name1: string;
  file_name2: string;
  db_path: string;
  ms1, ms2: TMemoryStream;
  ado_query: TADOQuery;
  uni_connection: TUniConnection;
  uni_query: TUniQuery;
  b1, b2: byte;
begin
  file_name1 := 'c:\aaa_ADO.ods';
  file_name2 := 'c:\aaa_Access.ods';
  db_path := ExtractFilePath(Application.ExeName) + 'jzxxsjx.mdb';

  ado_query := TADOQuery.Create(self);
  ado_query.ConnectionString := Format('Provider=Microsoft.Jet.OLEDB.4.0; Data Source=%s; User Id=admin; Password=',[db_path]);
  ado_query.Close;
  ado_query.SQL.Text := 'Select * from SYS_REPORT where id=''60bcde8c-fc5c-4d64-bccf-1af919adb485''';
  ado_query.Open;

  TBlobField(ado_query.FieldByName('O_VALUE')).SaveToFile(file_name1);

  uni_connection := TUniConnection.Create(Self);
  uni_connection.ProviderName :='ACCESS';
  uni_connection.database := db_path;
  uni_connection.Connect;

  uni_query := TUniQuery.Create(Self);
  uni_query.Connection := uni_connection;
  uni_query.sql.Text := 'Select * from SYS_REPORT where id=''60bcde8c-fc5c-4d64-bccf-1af919adb485''';
  uni_query.open;
  TBlobField(uni_query.FieldByName('O_VALUE')).SaveToFile(file_name2);

  ms1 := TMemoryStream.Create;
  ms2 := TMemoryStream.Create;

  try
    ms1.LoadFromFile(file_name1);
    ms2.LoadFromFile(file_name2);

    ms1.Seek(0, soFromBeginning);
    ms2.Seek(0, soFromBeginning);

    while ms1.Position  b2 then
        raise Exception.Create('!!! Content is not equal !!!');
    end;
  finally
    ms1.Destroy;
    ms2.Destroy;
  end;

  ShowMessage('Compare is finished: content is equal');
end;
And please provide us the result.

Posted: Thu 08 Jul 2010 13:14
by c123321
the result is

raise Exception.Create('!!! Content is not equal !!!');



you can insert file large then 10K and use ole field ,


the error will find, you can try it, you code is same

as mycode, so the result is the same. help

Posted: Thu 08 Jul 2010 16:03
by bork
Please send me your file that you cannot save correctly (you can fill this form: http://www.devart.com/company/contact.html). It seems like your problem depends on the file. As soon I will get this file I will try to help you.

Posted: Fri 09 Jul 2010 07:20
by c123321
you can use the example i had send, and if you get the demo ok, you can send to [email protected], thanks ,

i guess this bug will appare each file large than 10k;

Posted: Mon 12 Jul 2010 10:33
by c123321
update , wait

Posted: Mon 12 Jul 2010 10:52
by bork
I still haven't got you sample by E-mail. Please try to sent it to me again directly to my E-mail: borism at devart.com

I tried to store pictures with size more that 10K and they were stored correctly. So I need your sample to reproduce and resolve this issue.

Posted: Mon 12 Jul 2010 11:40
by c123321
had send file or you can send sample to me,

i do not know the sample download how to use;

Posted: Tue 13 Jul 2010 09:20
by bork
We have reproduced this problem and fixed it. This fix will be included in the next UniDAC build.