.NET Zip component, Delphi Zip component, Barcode .NET, BDE Replacement and other .NET and Delphi components from ComponentAce
Products Download Order Contact us

Search
 

Delphi/C++ Components
.NET Components
ActiveX Controls
Kylix Components

Download

Download
Download Commercial
Trial Limitations

Support

Submit Request
Support Options

Order

Purchase
Competitive Upgrade
Premium Support
Sales Policy
Upgrade Policy
License Types

Info

News
Mailing List
Articles
Testimonials



About Us
Partners
Links
Contact Us
Link to Us





Home > Delphi/C++ Components > Absolute Database > Web Sql Console Delphi Example

Absolute Database

Overview | Features | Requirements | Testimonials | SQL Samples | Code Samples | Screenshots | See Also | Download | Order
Web Sql Console Delphi Example
Illustrates how to use Absolute Db in web application (CGI or DLL)

Download Absolute Database | Learn more

unit Main;

interface
{$I CompVer.inc}

uses
{$IFDEF D5H}
HTTPProd,
{$ENDIF}
  Windows, SysUtils, Classes, HTTPApp,
  DB, ABSMain, ABSExcept,
  DSProd, DBWeb;

const DataBaseFileName = 'Demos.abs';

type
  TWebModule1 = class(TWebModule)
    PageProducer1: TPageProducer;
    dbDemos: TABSDatabase;
    Query: TABSQuery;
    DataSetTableProducer1: TDataSetTableProducer;
    Session: TABSSession;
    procedure WebModuleCreate(Sender: TObject);
    procedure PageProducer1HTMLTag(Sender: TObject; Tag: TTag;
      const TagString: String; TagParams: TStrings;
      var ReplaceText: String);
    procedure WebModuleDestroy(Sender: TObject);
    procedure DataSetTableProducer1FormatCell(Sender: TObject; CellRow,
      CellColumn: Integer; var BgColor: THTMLBgColor;
      var Align: THTMLAlign; var VAlign: THTMLVAlign; var CustomAttrs,
      CellData: String);
  private
    ErrorMsg: String;
  end;

var
  WebModule1: TWebModule1;
  DllFileName: String;

implementation

{$R *.dfm}


procedure TWebModule1.WebModuleCreate(Sender: TObject);
begin
  ErrorMsg := '';
  dbDemos.Close;
  try
    dbDemos.DatabaseFileName := ExtractFilePath(DllFileName) + DataBaseFileName;
    dbDemos.Open;
  except
    on e: Exception do ErrorMsg := e.Message;
  end;
end;


procedure TWebModule1.WebModuleDestroy(Sender: TObject);
begin
  Query.Close;
  dbDemos.Close;
end;


procedure TWebModule1.PageProducer1HTMLTag(Sender: TObject; Tag: TTag;
  const TagString: String; TagParams: TStrings; var ReplaceText: String);
var
  sl: TStringList;
  i: Integer;
  sql: String;
begin
  if TagString = 'ERROR' then
   begin
    if ErrorMsg <> '' then
      ReplaceText := 'Error openign Database: ' + dbDemos.DatabaseFileName +
                     ' Message: ' + ErrorMsg;
   end;

  if TagString = 'VERSION' then
   begin
    ReplaceText := dbDemos.CurrentVersion;
   end;

  if TagString = 'FILENAME' then
   begin
    ReplaceText := dbDemos.DatabaseFileName;
   end;

  if TagString = 'TABLES' then
   begin
    sl := TStringList.Create;
    try
      dbDemos.GetTablesList(sl);
      ReplaceText := '';
      for i:=0 to sl.Count-1 do
       ReplaceText := ReplaceText + sl[i] + #13#10;
    finally
      sl.Free;
    end;
   end;

  if TagString = 'SQL' then
   begin
    sql := Request.ContentFields.Values['sql'];
    if sql = '' then
     begin
      sl := TStringList.Create;
      try
        dbDemos.GetTablesList(sl);
        sql := 'select * from ' + sl[0];
      finally
        sl.Free;
      end;
      Request.ContentFields.Values['sql'] := sql;
     end;
    ReplaceText := sql;
   end;

  if TagString = 'RESULT_TABLE' then
   begin
    Query.SQL.Text := Request.ContentFields.Values['sql'];
    try
      DataSetTableProducer1.Columns.Clear;
      Query.Open;
      ReplaceText := Format('RecordCount = %d
'#13#10, [Query.RecordCount]) + DataSetTableProducer1.Content; Query.Close; except on e: EABSException do begin if (e.NativeError = 20001) then begin // It is ExecSQL. All OK. ReplaceText := Format('%d Rows Affected
'#13#10 ,[Query.RowsAffected]); end else begin Query.Close; ReplaceText := e.Message; end; end; on e: Exception do begin Query.Close; ReplaceText := e.Message; end; end; end; end; procedure TWebModule1.DataSetTableProducer1FormatCell(Sender: TObject; CellRow, CellColumn: Integer; var BgColor: THTMLBgColor; var Align: THTMLAlign; var VAlign: THTMLVAlign; var CustomAttrs, CellData: String); begin if CellRow = 0 then BgColor := '#BBBBBB' else if CellRow mod 2 = 0 then BgColor := '#DDDDDD'; end; initialization SetLength(DllFileName, 260); GetModuleFileName(HInstance, PChar(DllFileName), 260); end.


Download Absolute Database | Learn more


Product Info


Current version: 7.95
Released: February 08, 2023
Price: $ 149

downloadorder


Our Customers



Testimonials

We made three requests of the technical support personnel and despite the fact that these were all implementation questions (not bugs in their software) we received support within 24 hours. It is rare to get such good customer support these days and I really appreciate everything ComponentAce has done for us.

Jason Goodridge, Development Manager

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Dec 22, 2024