Take the 2-minute tour ×

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;


Dialogs, Grids, DBGrids, ADODB, DB, StdCtrls, DBCtrls;

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 declarations }
{ Public declarations }

  Form1: TForm1;


{$R *.dfm}

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

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


                    +  ADOTable1.FieldByName('VersionID').asstring + '.doc');



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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer


