Problem with the following mothod

Problem with the following mothod

Post by Graham Har » Fri, 07 Nov 2003 19:53:51


This method should retieve a XML Stream from a SQL server database. In one
project it works OK, in another it does not.

procedure TSendData.GetData(Data: TStringList);
var
ADOCommand, XMLStream: Variant;
begin
LogMessage('Reteiving data from the database');
Debug('GetDataFromDatabase:1 ' + FReferenceNumber, '');

ADOCommand := CoCommand.Create;
XMLStream := CoStream.Create;

ADOCommand.ActiveConnection := FADOConnection.ConnectionObject;
ADOCommand.CommandText:='exec sp_GetTerminalDataByID '+
FReferenceNumber;

XMLStream.Open;
XMLStream.LineSeparator := adCRLF;

Debug('GetDataFromDatabase:3 ' + FReferenceNumber, '');

ADOCommand.Properties.Item['Output Stream'].Value := XMLStream;
ADOCommand.Execute(, , adExecuteStream);

XMLStream.Position := 0;
Data.Text := '<APD><Forms><StopAndSearch>' +
XMLStream.ReadText(XMLStream.Size) + '</StopAndSearch></Forms></APD>';

Debug('Data Retrieved: ' + Data.Text + 'Reference Number: ' +
FReferenceNumber, '');
end;

The problem is that it access violates on ADOCommand.Execute(, ,
adExecuteStream);
Any ideas?

TIA

Graham Harris