Data Dictionary and Custom Data Templates
I am using RB7.02 with Delphi 5 and ADO
I have created some custom data templates which are almost straight
replica's of the Demos\End User\Custom data view TdvCustomerQuery to view
our Clients.
I am using ADO classes created exactly like the daDBBDE but using a
Connection rather than DatabaseName/Session. This all seems to work fine
except for 2 things?
1. When I select my custom data templates in the template tab (all works
fine) but then when I try to create another data view using the wizard (to
eventually connect to my data template view) the wizard seems to ignore the
data dictionary and shows all the tables in my database. Weird thing if a
use the wizard first then my custom templates then the wizard again the DD
is honored??
2. After selecting a table in the wizard and clicking Finish I get an Access
violation raised. Unfortunately I can not trace which line it is occuring on
(The stack dump seems to suggest TdaQueryDataView.CreateLinkObject) But the
dataview is created.
Any suggestions would be greatly appreciated
Jarrod
I have created some custom data templates which are almost straight
replica's of the Demos\End User\Custom data view TdvCustomerQuery to view
our Clients.
I am using ADO classes created exactly like the daDBBDE but using a
Connection rather than DatabaseName/Session. This all seems to work fine
except for 2 things?
1. When I select my custom data templates in the template tab (all works
fine) but then when I try to create another data view using the wizard (to
eventually connect to my data template view) the wizard seems to ignore the
data dictionary and shows all the tables in my database. Weird thing if a
use the wizard first then my custom templates then the wizard again the DD
is honored??
2. After selecting a table in the wizard and clicking Finish I get an Access
violation raised. Unfortunately I can not trace which line it is occuring on
(The stack dump seems to suggest TdaQueryDataView.CreateLinkObject) But the
dataview is created.
Any suggestions would be greatly appreciated
Jarrod
This discussion has been closed.
Comments
the data dictionary. Is UseDataDictionary set to true on the designer's
DataSettings property?
Can you reproduce the AV using the our custom dataview for the BDE demo?
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I have now sorted out my AV problem, but I still have the problem of the
Data Dictionary not being honoured after selecting a custom data view.
UseDataDictionary is set to true on the designers DataSettings property.
You can reproduce this problem if you grab your
CreateDataModCustOrderLinkedDataviewsADO sample project. 1 of the very few
ADO example programs I could find :-(.
Add a DataDictionary component and supporting ADO table comps to the form
and add a few tables/fields/joins from the Northwind database to the
datadictionary. I used customers, employees, Invoices, Orders, Products. Set
up the ADOConnection properties and DataSettings to UseDataDictionary.
Run the example program. You should find that if you click "create data
views" button then go into the designer & select the data tab, that if you
select file|new for a new dataview and use the wizard that the data
dictionary is not honoured.
If on the other hand you run the example program and do not "create data
views" first and go to the data tab and add a new dataview via the wizard
then the data dictionary is honoured.
Hopefully you get the same result I did. Is this a bug?
Regards,
Jarrod
I was able to solve my AV problem by either removing my FieldAlias name or
by setting both the Alias and the FieldAlias properties of my TdaField
SelectField objects. It was falling over in
TdaQueryDataView.CreateLinkObject because the first line in this procedure
would return nil for the MasterField object.
lMasterField := FSQL.MasterSQL.GetFieldForAlias(aMasterFieldAlias);
This is because it uses the FieldAlias is passed in as a parameter to locate
the master field rather than the Alias. Why does it accept a FieldAlias as a
parameter yet uses the Alias property in GetFieldForAlias rather than
GetFieldForFieldAlias?
Thanks for pointing this out. I changed the two lines of code and reran the
DADE QA and all tests indicate it works fine this way. I would imagine it
should have been coded originally with GetFieldForFieldAlias because it is a
FieldAlias that is getting passed from the list box in the Link Dialog and
not an Alias.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Any ideas on my other problem in this post above with where the data
dictionary is not honored after creating a custom data view? Eagerly
awaiting a solution ;-)
Cheers.
custom dataview templates are used. Can you reproduce this with our custom
dataview tempalte demo?
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
the replication example I gave you using the
CreateDataModCustOrderLinkedDataviewsADO example project from your tips
download area. If you missed it here are replication steps again....
"You can reproduce this problem if you grab your
CreateDataModCustOrderLinkedDataviewsADO sample project. 1 of the very few
ADO example programs I could find :-(.
Add a DataDictionary component and supporting ADO table comps to the form
and add a few tables/fields/joins from the Northwind database to the
datadictionary. I used customers, employees, Invoices, Orders, Products. Set
up the ADOConnection properties and DataSettings to UseDataDictionary.
Run the example program. You should find that if you click "create data
views" button then go into the designer & select the data tab, that if you
select file|new for a new dataview and use the wizard that the data
dictionary is not honoured.
If on the other hand you run the example program and do not "create data
views" first and go to the data tab and add a new dataview via the wizard
then the data dictionary is honoured."
settings are used. I did notice there was a missing Result := lPipeline when
the detail dataview was created. Check to make sure that is set. Here is the
project I used for this test:
http://www.digital-metaphors.com/tips/ADOdvWithDD.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
ADO for the test project.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks for the example program, but yep... still get the same problem with
your project.
If I click create dataviews first then launch the designer and try add
another dataview using the wizard then I see every table in the Northwind
database. But if I dont create the dataviews first & launch the designer
then the DD settings are used.
I am using RB 7.03 now with Delphi 5 and SQL 2000. Yeah I know.... Delphi 5
(don't get me started on that one!) We are probably upgrading once Delphi 8
comes out, so I am stuck with it until then.
I will try the example at home on my Delphi 7 version and see how it goes.
Are you able to try it there with Delphi 5?
Regards,
Jarrod
Looking into this problem further and debugging the ReportBuilder code I
can't see how yours could work?
In the example program the CreateCustomers first creates a dataview object
lDataView := TdaADOQueryDataView.Create(aDataModule);
Walking through the create of the TdaADOQueryDataView.Create function it
calls SetSQLObjectDataDictionary. Stepping through this procedure the first
line...
if (FSQL.DataDictionary = nil) and (Parent is TdaDataModule) then
always returns false becase the Parent of the datamodule has not been set
and is nil. Therefore the FSQL.DataDictionary is nil.
Then when the first table is added to the SQL object in CreateCustomers it
first creates the MetaDataCache in the procedure
TdaMetaData.GetTables(aTables: TList)
The first call to GetTables will execute GetTablesFromSession(aTables)
because the DataDictionary will be nil because because the
SQL.DataDictionary object is nil.
Therefore any successive call to the MetaData.GetTables will return the full
list of tables not those in the data dictionary.
This is different if the Dataview wizard is called first before creating
custom dataviews because it will call TdaQueryWizard.Execute before the
TdaMetaData.GetTables which half way through the procedure will first set
the SQL objects DataDictionary (see code extract below)
if DataSettings.UseDataDictionary then
FForm.SQL.DataDictionary :=
TppDataDictionary(DataSettings.DataDictionary)
TdaMetaData.GetTables(aTables: TList) function will then call
GetTablesFromDataDictionary(aTables); because the data dictionary is NOT
nil.
Sorry for the long winded explanation, but I hope it is clear.
Any possible work arounds for this?
You're right, the table names are in the cache. I was off in the wrong track
trying to determine if the dictionary was being used, and it was, however,
the table names were already in the cache, although the joins information
was still coming from the data ditcionary, so I guessed the dictionary was
working, because my dictionary listed all the tables that were available.
Once I removed some entries form the dictionary I saw the problem. You can
control mouse click over the empty area of DADE and it will popup the meta
data cache listing. So, to solve the problem, add a line of code to clear
the cache after creating the dataviews so that the data dictionary will be
used for all new dataviews the user creates.
uses
daMetaDataManager;
---
--
-
gMetaDataManager.Clear;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com