Marco's Web Center

Menu for Development

Site Menu
Object Pascal Handbook
Delphi Handbooks Collection
Mastering Borland Delphi 2005
(Old) White Papers
(Old)Tools
(Old) Conferences

My Other Sites
Italian Site (www.marcocantu.it)
the delphi search

Spirit of delphi

Advertising
Home My Blog Books Object Pascal Marco

Home: Code Repository: Mastering Delphi 5

Project ADOPRIMER

Project Structure


ADOPRIMER.DPR

program AdoPrimer;

uses
  Forms,
  FormPrimer in 'FormPrimer.pas' {Form1},
  DmPrimer in 'DmPrimer.pas' {DataModule2: TDataModule};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TDataModule2, DataModule2);
  Application.Run;
end.

FORMPRIMER.PAS

unit FormPrimer;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, ADODB, DBCtrls, DBTables, Grids, DBGrids, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    DBGrid1: TDBGrid;
    DBNavigator1: TDBNavigator;
    DBMemo1: TDBMemo;
    Splitter1: TSplitter;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses DmPrimer;

{$R *.DFM}

end.

DMPRIMER.PAS

unit DmPrimer;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, ADODB;

type
  TDataModule2 = class(TDataModule)
    ADODataSet: TADODataSet;
    ADOConnection: TADOConnection;
    DataSource: TDataSource;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DataModule2: TDataModule2;

implementation

{$R *.DFM}

end.

FORMPRIMER.DFM

object Form1: TForm1
  Left = 245
  Top = 179
  Width = 596
  Height = 367
  Caption = 'AdoPrimer'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Splitter1: TSplitter
    Left = 0
    Top = 217
    Width = 588
    Height = 3
    Cursor = crVSplit
    Align = alTop
  end
  object DBGrid1: TDBGrid
    Left = 0
    Top = 25
    Width = 588
    Height = 192
    Align = alTop
    DataSource = DataModule2.DataSource
    TabOrder = 0
    TitleFont.Charset = DEFAULT_CHARSET
    TitleFont.Color = clWindowText
    TitleFont.Height = -11
    TitleFont.Name = 'MS Sans Serif'
    TitleFont.Style = []
    Columns = <
      item
        Expanded = False
        FieldName = 'LAST_NAME'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'FIRST_NAME'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'ACCT_NBR'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'ADDRESS_1'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'CITY'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'STATE'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'ZIP'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'TELEPHONE'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'DATE_OPEN'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'SS_NUMBER'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'BIRTH_DATE'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'RISK_LEVEL'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'OCCUPATION'
        Visible = True
      end
      item
        Expanded = False
        FieldName = 'OBJECTIVES'
        Visible = True
      end>
  end
  object DBNavigator1: TDBNavigator
    Left = 0
    Top = 0
    Width = 588
    Height = 25
    DataSource = DataModule2.DataSource
    VisibleButtons = [nbFirst, nbPrior, nbNext, nbLast, nbInsert, nbDelete, nbEdit, nbPost, nbCancel]
    Align = alTop
    TabOrder = 1
  end
  object DBMemo1: TDBMemo
    Left = 0
    Top = 220
    Width = 588
    Height = 120
    Align = alClient
    DataField = 'INTERESTS'
    DataSource = DataModule2.DataSource
    TabOrder = 2
  end
end

DMPRIMER.DFM

object DataModule2: TDataModule2
  OldCreateOrder = False
  Left = 192
  Top = 158
  Height = 432
  Width = 760
  object ADODataSet: TADODataSet
    Active = True
    Connection = ADOConnection
    CursorType = ctStatic
    CommandText = 'select * from clients'
    FieldDefs = <
      item
        Name = 'LAST_NAME'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'FIRST_NAME'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'ACCT_NBR'
        Attributes = [faFixed]
        DataType = ftFloat
      end
      item
        Name = 'ADDRESS_1'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'CITY'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'STATE'
        DataType = ftString
        Size = 2
      end
      item
        Name = 'ZIP'
        DataType = ftString
        Size = 5
      end
      item
        Name = 'TELEPHONE'
        DataType = ftString
        Size = 12
      end
      item
        Name = 'DATE_OPEN'
        Attributes = [faFixed]
        DataType = ftDate
      end
      item
        Name = 'SS_NUMBER'
        Attributes = [faFixed]
        DataType = ftFloat
      end
      item
        Name = 'PICTURE'
        DataType = ftString
        Size = 15
      end
      item
        Name = 'BIRTH_DATE'
        Attributes = [faFixed]
        DataType = ftDate
      end
      item
        Name = 'RISK_LEVEL'
        DataType = ftString
        Size = 8
      end
      item
        Name = 'OCCUPATION'
        DataType = ftString
        Size = 20
      end
      item
        Name = 'OBJECTIVES'
        DataType = ftString
        Size = 10
      end
      item
        Name = 'INTERESTS'
        DataType = ftString
        Size = 120
      end>
    Parameters = <>
    StoreDefs = True
    Left = 120
    Top = 24
  end
  object ADOConnection: TADOConnection
    Connected = True
    ConnectionString =
       'Provider=MSDASQL.1;Persist Security Info=False;Mode=Read|Write;C' +
      'onnect Timeout=15;Extended Properties="DSN=dBASE Files;DBQ=c:\PR' +
      'OGRAM FILES\COMMON FILES\BORLAND SHARED\DATA;DefaultDir=c:\PROGR' +
      'AM FILES\COMMON FILES\BORLAND SHARED\DATA;DriverId=533;MaxBuffer' +
      'Size=2048;PageTimeout=5;";Locale Identifier=1033'
    LoginPrompt = False
    Mode = cmReadWrite
    Left = 40
    Top = 24
  end
  object DataSource: TDataSource
    DataSet = ADODataSet
    Left = 192
    Top = 24
  end
end