TAstaServerSocket.OnExecSQLParamList


 

Applies to
TAstaServerSocket

 

Declaration
type TAstaServerExecSQLParamListEvent = procedure(Sender: TObject;
  ClientSocket:
TCustomWinSocket; AQuery: TComponent;
  DataBaseStr, SQLString:
string; var TheResult: Boolean;
  
var Msg: string; ParamList: TAstaParamList) of object;

 

Description
This is the event coded that allows Exec statements to work for ASTA clients. ASTA clients will send in parameterized queries that appear as the SQLString and ParamList parameters. The server must be able to handle parameterized queries in order to be able to update and insert blobs and memos. To support the
RowsAffected property of the AstaclientDataSet the OnExecRowsAffected Event of the AstaServer must be coded.

 

See Coding ASTA Servers for steps to create an ASTA server.

 

Here is an example from the AstaBDEServer. Depending on the threading model in effect, the AQuery parameter will be supplied by the ThreadedDBSupplyQueryEvent. Since ASTA suports any type of component for use with ASTA servers, the example below type casts the AQuery parameter as a BDE TQuery since this example was from the AstaBDEServer.

 

procedure TForm1.AstaServerSocket1ExecSQLParamList(Sender: TObject;
  ClientSocket: TCustomWinSocket; AQuery: TComponent; DataBaseStr,
  SQLString:
string; var TheResult: Boolean; var Msg: string;
  ParamList: TAstaParamList);

var

  I: Integer;

begin

  try

    TheResult := False; //we need to know if the exec is successful

    TQuery(AQuery).SQL.Clear;

    TQuery(AQuery).SQL.Add(SqlString);

    for I := 0 to ParamList.Count - 1 do begin

      if ParamList[i].IsNull then begin

        TQuery(AQuery).Params[i].DataType := ParamList[i].DataType;

        TQuery(AQuery).Params[i].Clear;

        TQuery(AQuery).Params[i].Bound := True;

      end

      else

        case ParamList[i].DataType of

          ftString: TQuery(AQuery).Params[i].AsString :=

                      ParamList[i].AsString;

          ftInteger,

          ftSmallint,

          ftWord: TQuery(AQuery).Params[i].AsInteger :=

                    ParamList[i].AsInteger;

          ftFloat: TQuery(AQuery).Params[i].AsFloat :=

                     ParamList[i].AsFloat;

          ftBoolean: TQuery(AQuery).Params[i].AsBoolean :=

                       ParamList[i].AsBoolean;

          ftTime: TQuery(AQuery).Params[i].AsTime :=

                    ParamList[i].AsTime;

          ftDate,

          ftDatetime: TQuery(AQuery).Params[i].AsDateTime :=

                        ParamList[i].AsDateTime;

          ftBlob,

          ftGraphic: TQuery(AQuery).Params[i].SetBlobData(

                       pchar(ParamList[i].AsString),

                       Length(ParamList[i].AsString));

          ftMemo: TQuery(AQuery).Params[i].AsMemo :=

                    ParamList[i].AsString;

        end;

    end;

    TQuery(AQuery).ExecSQL;

    TheResult := True;

  except

    begin

      Msg := EDataBaseError(ExceptObject).Message;

      LogIt('Exec SQL Error->' + Msg);

    end;

  end;

end;

 



ASTA Overview TAstaServerSocket.OnEncrypt TAstaServerSocket.OnInsertAutoIncrementFetch