I want to converting from delphi command to sql script

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ttsoft
Posts: 1
Joined: Tue 04 Dec 2007 15:14

I want to converting from delphi command to sql script

Post by ttsoft » Tue 04 Dec 2007 15:39

help me...... i send problem from thailand . Thanks,Titipong

source................

procedure TSePurchaseOrder.ToolButton8Click(Sender: TObject);
var SwAQTY:double ;
SwADis:double ;
SwZQTY:double ;
SeQuery1:TMSQuery;
ShQuery1:TMSQuery;
begin


ShQuery1 := TMSQuery.Create(self) ;
ShQuery1.Connection := main.MSConnection1 ;

SeQuery1 := TMSQuery.Create(self) ;
SeQuery1.Connection := main.MSConnection1 ;
SeQuery1.SQL.Add('SELECT * ');
SeQuery1.SQL.Add('FROM Bill_BiAdPo Bienpo ');
SeQuery1.Open;
SeQuery1.Options.StrictUpdate := FALSE ;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SeQuery1.First ;
while not SeQuery1.Eof do begin
SwZQTY := SeQuery1.FieldByName('AQty' ).asFloat ;
ShQuery1.Close;
ShQuery1.SQL.Clear;
ShQuery1.SQL.Add('SELECT * FROM Bill_TransC TransC , Bill_TransNo TransNo ' );
ShQuery1.SQL.Add('WHERE (TransNo.link = ClTransC.link ) ' );
ShQuery1.SQL.Add(' AND (TransNo.SWAPSTATUS = '+Chr(39)+'A'+Chr(39) + ' )' );
ShQuery1.SQL.Add(' AND (TransNo.Status '+Chr(39) + 'Uses' + Chr(39) + ')' );
ShQuery1.SQL.Add(' AND (Transc.Number = '+Chr(39) + SeQuery1.FieldByName('Number').asString + Chr(39)+')' );
ShQuery1.SQL.Add(' AND (TransNo.TYPEBILL = '+Chr(39)+'A'+Chr(39)+' or TransNo.TYPEBILL = '+Chr(39)+'B'+Chr(39)+' )' );
ShQuery1.SQL.Add(' Order by TransNo.NoBill ' );
ShQuery1.Open ;
ShQuery1.Options.StrictUpdate := FALSE ;
ShQuery1.First ;
SwADis := 0 ;
SwAQTY := 0 ;
while not ShQuery1.Eof do begin
SwAQTY := SwAQTY + ShQuery1.FieldByName('AQTY').asFloat ;
if not ( ShQuery1.State in [dsedit, dsinsert] ) then ShQuery1.Edit ;
if (ShQuery1.FieldByName('TYPEBILL').asstring = 'A' ) then begin
ShQuery1.FieldByName('ZQTY').asFloat := SwZQTY + ShQuery1.FieldByName('AQTY').asFloat ;
SwADis := SwADis - ShQuery1.FieldByName('AQTY').asFloat ;
end else begin
ShQuery1.FieldByName('ZQTY').asFloat := SwZQTY - ShQuery1.FieldByName('AQTY').asFloat ;
SwADis := SwADis + ShQuery1.FieldByName('AQTY').asFloat ;
end;
ShQuery1.Post ;
SwZQTY := ShQuery1.FieldByName('ZQTY').asFloat ;
ShQuery1.Next ;
end ;
if not ( SeQuery1.State in [dsedit, dsinsert] ) then SeQuery1.Edit ;
SeQuery1.FieldByName('ADis').asFloat := SwADis ;
SeQuery1.Post ;
SeQuery1.Next ;
ShQuery1.Close ;
end ;
SeQuery1.Close ;
SeQuery1.Free ;

ShQuery1.Free ;

end;

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 05 Dec 2007 08:38

Please, describe in more details what's wrong with this code. What do you expect from it, and what it actually does?
You can make a complete small sample and at send it to sdac*crlab*com to demonstrate it, including script to create server objects.

Also supply me the following information:
- exact version of SDAC. You can see it in the About sheet of TMSConnection Editor;
- exact version of your IDE;
- exact version of SQL server and client. You can see it in the Info sheet of TMSConnection Editor.

Post Reply