Re: ADOX - Import type library into Delphi 2007
- From: Pontus Berg <pontus@xxxxxxxxxxxxxxxxx>
- Date: Tue, 20 May 2008 23:35:52 +0200
Vitali Kalinin skrev:
Now I am see what you problem is. Just uncheck generate component wrappers checkbox in import dialog. You don't need it as components, use it as is - through interfaces. In MSDN you will find detailed development reference. To instantinate root object Catalog you could use this code snippet:
function CreateCatalog(Source : TADOConnection) : _Catalog;
begin
Result := CoCatalog.Create;
Result.Set_ActiveConnection(ADOConnection.ConnectionObject);
end;
In my scenario I have one set of fields on the TADODataSet list of fields and not exactly the same in the MDB file on disk. The assumption is that the EXE file developed so that it requires new fields to be available and the aim is to add them at runtime.
I'd be all ears on a suggestion on how to add fields to the MDB based on the findings in the field definitions of the TADODataset.
I have identified the missing fields using this:
procedure TMainForm.ProgressActivate;
var ErrorFound: boolean;
begin
// ShowMessage('Data structure being validated ...');
FieldsInClientList.Clear;
FieldsOnDiskList.Clear;
// An error will be generated if the tabledefinitions do not match
try
ADO_Progress.Active := true;
ErrorFound := false;
except
ErrorFound := true;
end;
//Contains what I have in the DB file...
ADOConnection1.GetFieldNames('Progress', FieldsOnDiskList.Items);
//Contains what I want to have! - Defined by the DefFields
ADO_Progress.GetFieldNames(FieldsInClientList.Items);
if ErrorFound then begin
ShowMessage('Database not in most recent format'+#13+'On disk: '+
IntToStr(FieldsOnDiskList.Count)+#13+'In client: '+
IntToStr(FieldsInClientList.Count));
DBCrossReference; //Here the actual identification of the field takes place!
end;
end;
(Table name is "Progress", TADODataSet is "ADO_Progress". The "FieldsOnDiskList" and "FieldsInClientList" are two TListBox:es that I store the definitions in to explore them further.
I then show the actual fields here:
procedure TMainForm.DBCrossReference;
var
DiskCount: Integer;
ClientCount: Integer;
found: Boolean;
begin
// Compare the first way
for DiskCount := 0 to FieldsOnDiskList.Count - 1 do
begin
found := false;
for ClientCount := 0 to FieldsInClientList.Count - 1 do
begin
if FieldsOnDiskList.Items[DiskCount] = FieldsInClientList.Items[ClientCount] then
found := true;
end;
if Found = false then
begin
ShowMessage('Not found on disk: ' + FieldsOnDiskList.Items[DiskCount]);
end;
//Add to disk
end;
// Compare the other way
for ClientCount := 0 to FieldsInClientList.Count - 1 do
begin
found := false;
for DiskCount := 0 to FieldsOnDiskList.Count - 1 do
begin
if FieldsInClientList.Items[ClientCount] = FieldsOnDiskList.Items[DiskCount] then
found := true;
end;
if Found = false then
begin
ShowMessage('Not found in client: ' + FieldsInClientList.Items[ClientCount]);
end;
//Add to client
end;
end;
/Pontus
.
- Follow-Ups:
- Re: ADOX - Import type library into Delphi 2007
- From: Vitali Kalinin
- Re: ADOX - Import type library into Delphi 2007
- References:
- ADOX - Import type library into Delphi 2007
- From: Pontus Berg
- Re: ADOX - Import type library into Delphi 2007
- From: Vitali Kalinin
- Re: ADOX - Import type library into Delphi 2007
- From: Pontus Berg
- Re: ADOX - Import type library into Delphi 2007
- From: Vitali Kalinin
- ADOX - Import type library into Delphi 2007
- Prev by Date: Re: How to implement nested transaction
- Next by Date: Re: ADOX - Import type library into Delphi 2007
- Previous by thread: Re: ADOX - Import type library into Delphi 2007
- Next by thread: Re: ADOX - Import type library into Delphi 2007
- Index(es):