views:

56

answers:

1

Delphi 7 SQLSERVER 2000

I am having a problem with a legacy application that I am unable to recompile, because when i do I lose the ability to retrieve documents from a text field they are stored in and write to disk, I only get the first 8 bytes. I have a much larger application, but a really simple app is recreating the issue.

Code is below. Connection string used to connect is.

Provider=SQLOLEDB.1;Password=toflidium;Persist Security Info=True;User ID=sa;Initial Catalog=DocManager;Data Source=DELPHIBOX;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=DELPHIBOX;Use Encryption for Data=False;Tag with column collation when possible=False

The entire code for the test case

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, ADODB, DB, StdCtrls, DBCtrls;

type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Edit1: TEdit;
Button1: TButton;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DataSource1: TDataSource;
ADOTable1: TADOTable;
DataSource2: TDataSource;
DBGrid1: TDBGrid;
ADOQuery1DocumentDataID: TAutoIncField;
ADOQuery1VersionID: TIntegerField;
ADOQuery1DocName: TStringField;
ADOQuery1ActualDoc: TMemoField;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  sql : string;
begin

  sql := 'Select Top 1 * from tblDocumentData where VersionID = ' + ADOTable1.FieldByName('VersionID').asstring ;
  ADOQuery1.Close;
  ADOQuery1.SQL.Text := sql;

  ADOQuery1.Open;   

  TBlobField(ADOQuery1.FieldByName('ActualDoc')).SaveToFile('c:\temp\temp\myfile' 
                    +  ADOTable1.FieldByName('VersionID').asstring + '.doc');

end;

end.

This is the entire file writen to dis

ÐÏࡱá

I should recieve an entire 20 - 50K word Document.

I rebuilt an entire machine to see if something had been set wrong on my dev machine and I get the same issue on rebuilding. if I just build and try against live database I have same issue, but the older version (now about 4 years old) works fine.

Any ideas?

+1  A: 

I found the problem. I must have moved machines after the previous update and not installed Update 1 for Delphi 7.

Installed the update and it fixed the problem - should have been uptodate before I went looking for other problems.

Hopefully this answer might help some others.

Toby Allen