delphi ADO

5288 단어 Delphi

1)  t_ADOConnection: TADOConnection;

2)  iRet := KT_ConnectDB('','',clUseServer,cmReadWrite,t_ADOConnection,sErrMessage);
    iRet := KT_SetTransaction('READ UNCOMMITTED',sErrMessage);

3)
/**
 *
 *  Display
 */

    lKTDataSet       : TKtAdoDataset;
    lt_ADOConnection : TAdoConnection;
  try
    if (KTAxesDB(lt_ADOConnection,lKTDataset) = ST_OK) then begin   
      lKTDataset.CommandText := sSql;

      lKTDataset.KTFirstRead;

      iT3019 := lKTDataset.FieldbyName('T3019');

      lKTDataset.KTNext = ST_OK;
   end
  finally
      KTCloseDB(lKTDataset);
  end;

insert create delele update

	 lKTCommand       : TKTADOCommand;
  	 lt_ADOConnection : TAdoConnection;

	 if  (KtCmndDB(lt_ADOConnection,lKTCommand) = ST_OK) then begin

	  KtCloseDB(lKTDataSet);
    	  KtCloseCmndDB(lKTCommand);

//******************************************************************************
//  KtADOExecute: コマンド  
//******************************************************************************
Function KtADOExecute(COMMAND: TKTADOCommand; CONNECTION: TADOConnection;
                      COMMANDTYPE: TCommandType; COMMANDTEXT: String) : Integer;
begin
  COMMAND.Connection  := CONNECTION;
  COMMAND.CommandType := COMMANDTYPE;
  COMMAND.CommandText := COMMANDTEXT;

  Result := COMMAND.KTExecute;
end;

//***********************************************************************
//    module name   : DB                                              *
//----------------------------------------------------------------------*
//    style         : KTAxesDB                                          *
//***********************************************************************
Function KTAxesDB(var t_ADOConnection: TAdoConnection; var KTDataset: TKtAdoDataset) : Integer;
var
  iSt         : Integer;
  sErrMessage : String;
begin
  Result    := ST_OK;
  KTDataSet := TKtAdoDataset.Create(NIL);
  try
  
    iSt := KT_ConnectDB('','',clUseServer,cmReadWrite,t_ADOConnection,sErrMessage);
    if (iSt <> ST_OK) then begin
      Err_Dsp(iSt,Get_Message('COMMON','0001')+#13#10+sErrMessage,NIL);        
      Result := iSt;
      Exit;
    end;

    if (KTDataSet.Active = True) then KTDataSet.Active := False;

    KTDataSet.Connection     := t_ADOConnection;
    KTDataSet.CommandType    := cmdText        ;
    KTDataSet.CursorLocation := clUseServer    ;
    KTDataSet.LockType       := ltOptimistic   ;
  finally
  end;  
end;

//***********************************************************************
//    module name   : DB                                              *
//----------------------------------------------------------------------*
//    style         : KTCloseDB                                         *
//***********************************************************************
Function KTCloseDB(var KTDataset: TKtAdoDataset) : Integer;
begin
  Result := ST_OK;
  if (KTDataSet.Active = True) then KTDataSet.Active := False;
  KTDataSet.Connection := nil;
  KTDataSet.Free;
end;


//******************************************************************************
//  KTCmndDB : DB    (ADOCommand)
//------------------------------------------------------------------------------
//  CONNECTION : TADOConnection
//  COMMAND    : TKTADOCommand
//   り      : Integer
//******************************************************************************
Function KtCmndDB(var CONNECTION: TADOConnection; var COMMAND: TKTADOCOMMAND) : Integer;
var
  iRet: Integer;
  sErrMessage: String;
begin
  Result := ST_OK;
  COMMAND := TKTADOCommand.Create(NIL);
  try
    //Connection   
    iRet := KT_ConnectDB('','',clUseClient,cmReadWrite,CONNECTION,sErrMessage);
    if (iRet <> ST_OK) then begin
      Err_Dsp(iRet,Get_Message('COMMON','0001')+#13#10+sErrMessage,NIL);  //サーバー  に  しました。
      Result := iRet;
      Exit;
    end;

    COMMAND.CommandTimeout := 0;
    COMMAND.Connection     := CONNECTION;
    COMMAND.CommandType    := cmdText;
  finally
  end;
end;


//******************************************************************************
//  KTCloseCmndDB:DB    (ADOCommand)
//------------------------------------------------------------------------------
//  COMMAND    : TKTADOCommand
//   り      : Integer
//******************************************************************************
Function KtCloseCmndDB(var COMMAND: TKTADOCommand) : Integer;
begin
  Result := ST_OK;
  COMMAND.Connection := nil;
  COMMAND.Free;
end;


좋은 웹페이지 즐겨찾기