Access ole field can not fetch correct, why?
Posted: Sat 03 Jul 2010 04:13
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]
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]