Question : From BCD to ADO

Dear Experts,

I have a BCD example and I want to convert it to ADO.
It contains 1 TDatabase component and 6 TQuery-components.
I can not figure out with the code and the designcode of the
example what the structure of the database is!
1. How many tables are there and how are they called?
2. What are the column names of every table?
2. How are the tables connected with eachother?
3. And are there primary and foreign keys?
Can someone figure out what the structure of the database is
so I can create a predefined MS-Access database?

Who is willing to help me?
I have put some of the procedures and the designcode that
comes with the TDatabase component and the 6 TQuery-components
in the code-section.

Peter Kiers
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
object NeedApptsQuery: TQuery
    DatabaseName = 'UTF'
    SQL.Strings = (
      'Select * From GroupLink, GroupAppt'
      '  Where (SchedName = :SchedName)'
      '    And (GroupLink.ApptID = GroupAppt.ApptID)'
      '    And ((StartDate >= :D1) and (EndDate <= :D2))')
    Left = 392
    Top = 560
    ParamData = <
      item
        DataType = ftString
        Name = 'SchedName'
        ParamType = ptUnknown
      end
      item
        DataType = ftDate
        Name = 'D1'
        ParamType = ptUnknown
      end
      item
        DataType = ftDate
        Name = 'D2'
        ParamType = ptUnknown
      end>
  end
  object ApptSchedulesQuery: TQuery
    DatabaseName = 'UTF'
    RequestLive = True
    SQL.Strings = (
      'Select * From GroupLink'
      '  Where ApptID = :ApptID')
    Left = 424
    Top = 560
    ParamData = <
      item
        DataType = ftString
        Name = 'ApptID'
        ParamType = ptUnknown
      end>
  end
  object GetApptQuery: TQuery
    DatabaseName = 'UTF'
    RequestLive = True
    SQL.Strings = (
      'Select * From GroupAppt'
      '  Where ApptID = :ApptID')
    Left = 456
    Top = 560
    ParamData = <
      item
        DataType = ftString
        Name = 'ApptID'
        ParamType = ptUnknown
      end>
  end
  object DeleteApptLinkQuery: TQuery
    DatabaseName = 'UTF'
    SQL.Strings = (
      'Delete From GroupLink'
      '  Where ApptID = :ApptID')
    Left = 488
    Top = 560
    ParamData = <
      item
        DataType = ftString
        Name = 'ApptID'
        ParamType = ptUnknown
      end>
  end
  object DeleteApptQuery: TQuery
    DatabaseName = 'UTF'
    SQL.Strings = (
      'Delete From GroupAppt'
      '  Where ApptID = :ApptID')
    Left = 520
    Top = 560
    ParamData = <
      item
        DataType = ftString
        Name = 'ApptID'
        ParamType = ptUnknown
      end>
  end
  object SchedulesQuery: TQuery
    DatabaseName = 'UTF'
    SQL.Strings = (
      'Select Distinct(SchedName) From GroupLink')
    Left = 552
    Top = 560
  end
  object dbUTF: TDatabase
    DatabaseName = 'UTF'
    DriverName = 'STANDARD'
    LoginPrompt = False
    Params.Strings = (
      'DEFAULT DRIVER=PARADOX'
      'ENABLE BCD=FALSE')
    SessionName = 'Default'
    Left = 448
    Top = 528
  end
end
(*---------------------------------------------------*)
procedure TMainForm.utfSchedMgrDeleteAppt(Sender: TObject; Appt: TJvTFAppt);
begin
  With DeleteApptQuery do
    Begin
      ParamByName('ApptID').AsString := Appt.ID;
      ExecSQL;
    End;
  With DeleteApptLinkQuery do
    Begin
      ParamByName('ApptID').AsString := Appt.ID;
      ExecSQL;
    End;
end;
(*---------------------------------------------------*)
procedure TMainForm.utfSchedMgrLoadBatch(Sender: TObject; BatchName: string;
  BatchStartDate, BatchEndDate: TDate);
var
  Appt : TJvTFAppt;
  NewAppt : Boolean;
begin
  With NeedApptsQuery do
    Begin
      ParamByName('D1').AsDate := BatchStartDate;
      ParamByName('D2').AsDate := BatchEndDate;
      ParamByName('SchedName').AsString := BatchName;
      Open;
      First;
      While not EOF do
        Begin
          utfSchedMgr.RequestAppt(FieldByName('ApptID').AsString,
            Appt, NewAppt);
          If NewAppt Then
            Begin
              Appt.SetStartEnd(FieldByName('StartDate').AsDateTime,
                               FieldByName('StartTime').AsDateTime,
                               FieldByName('EndDate').AsDateTime,
                               FieldByName('EndTime').AsDateTime);
              Appt.Description := FieldByName('Description').AsString;
              Appt.AlarmEnabled := FieldByName('AlarmEnabled').AsBoolean;
              Appt.AlarmAdvance := FieldByName('AlarmAdvance').AsInteger;
              With ApptSchedulesQuery do
                Begin
                  ParamByName('ApptID').AsString := Appt.ID;
                  Open;
                  First;
                  While not EOF do
                    Begin
                      Appt.AddSchedule(FieldByName('SchedName').AsString);
                      Next;
                    End;
                  Close;
                End;
            End;
          Next;
        End;
      Close;
    End;
end;
(*---------------------------------------------------*)
procedure TMainForm.utfSchedMgrPostAppt(Sender: TObject; Appt: TJvTFAppt);
var
  I : Integer;
begin
  With GetApptQuery do
    Begin
      ParamByName('ApptID').AsString := Appt.ID;
      Open;
      If RecordCount > 0 Then
        Edit
      Else
        Begin
          Insert;
          FieldByName('ApptID').AsString := Appt.ID;
        End;
      FieldByName('StartDate').AsDateTime := Appt.StartDate;
      FieldByName('StartTime').AsDateTime := Appt.StartTime;
      FieldByName('EndDate').AsDateTime := Appt.EndDate;
      FieldByName('EndTime').AsDateTime := Appt.EndTime;
      FieldByName('Description').AsString := Appt.Description;
      FieldByName('AlarmEnabled').AsBoolean := Appt.AlarmEnabled;
      FieldByName('AlarmAdvance').AsInteger := Appt.AlarmAdvance;
      Post;
      Close;
    End;
  With DeleteApptLinkQuery do
    Begin
      ParamByName('ApptID').AsString := Appt.ID;
      ExecSQL;
    End;
  With ApptSchedulesQuery do
    Begin
      ParamByName('ApptID').AsString := Appt.ID;
      Open;
      For I := 0 to Appt.ScheduleCount - 1 do
        Begin
          Insert;
          FieldByName('ApptID').AsString := Appt.ID;
          FieldByName('SchedName').AsString := Appt.Schedules[I];
          Post;
        End;
      Close;
    End;
end;
(*---------------------------------------------------*)
procedure TMainForm.utfSchedMgrRefreshAppt(Sender: TObject; Appt: TJvTFAppt);
begin
  With GetApptQuery do
    Begin
      ParamByName('ApptID').AsString := Appt.ID;
      Open;
      If RecordCount = 1 Then
        Begin
          Appt.SetStartEnd(FieldByName('StartDate').AsDateTime,
                           FieldByName('StartTime').AsDateTime,
                           FieldByName('EndDate').AsDateTime,
                           FieldByName('EndTime').AsDateTime);
          Appt.Description := FieldByName('Description').AsString;
          Appt.AlarmEnabled := FieldByName('AlarmEnabled').AsBoolean;
          Appt.AlarmAdvance := FieldByName('AlarmAdvance').AsInteger;
        End;
      Close;
    End;
  Appt.ClearSchedules;
  With ApptSchedulesQuery do
    Begin
      ParamByName('ApptID').AsString := Appt.ID;
      Open;
      First;
      While not EOF do
        Begin
          Appt.AddSchedule(FieldByName('SchedName').AsString);
          Next;
        End;
      Close;
    End;
end;
(*---------------------------------------------------*)

Answer : From BCD to ADO

PS.   how to use queries with ADO  see  http://delphi.about.com/od/database/l/aa050101a.htm

if you want to use eg. MS ACCESS  and let your program use the ZEOS database components  http://zeos.firmos.at/portal.php

,    big advantage not only   MS ACCESSS, but you may use then also MS SQL server, MY SQL, .....  -> biggest flexibility for support of more database systemes

 

Random Solutions  
 
programming4us programming4us