Where do you set the DatabaseType?

edited June 2011 in DADE

I've been struggling with this one for a few hours now: where do you
set the database type to, for example, dtNexusDB?

Even if I run the NexusDB demo included in RB12, when I get to the
SQLChanged method of the Data View, the SQL.DatabaseType property is
either dtOther (in my app) or dtParadox (in the Nexus demo). I've made
sure the Session's GetDatabaseType method returns dtNexusDB. However,
I've traced the code and I don't see where is this method being used in
a manner that indicates that the database type is being set properly in
the SQL object of the data view.

I use an end user reporting solution in which I load a form with a
ppReport, a ppDesigner, a ppReportExplorer and a ppDataDictionary. On
the form create, I set ppDesigner.DataSettings.DatabaseType to
dtNexusDB, and if at runtime I open the Report Explorer, open a report
and look at the data settings dialog, everything looks as expected:
DatabaseType = dtNexusDB.

However, if I close the report, and print preview it from the Report
Explorer or load the report directly into the ppReport and try to print
it, in the Data View's SQLChanged method, the SQL.DatabaseType is still
dtOther, so SQL.MagicSQLText returns incorrect SQL (in this case, I'm
having an issue with the TIMESTAMP keyword required by NexusDB3).

The only way I was able to solve this was by forcing SQL.DatabaseType
:= dtNexusDB right there in the SQLChanged method, before the
SQL.MagicSQLText call.

So, where is the SQL.DatabaseType property of the data view being set
in the RB code, so that I can take it from there and try to figure out
what I'm doing wrong?

Thanks in advance!

Using RB12.04 Build 77


  • edited June 2011
    After further research...

    It appears none of my existing reports have the DatabaseType property
    of the TdaSQL object in the .RTM files or in the database templates
    (they were saved using RB6.03). However, the one I just saved with
    RB12, has this property. So if I now understand correctly, this is how
    the DatabaseType property works:

    1. It is set in the Designer's DataSettings.
    2. When saved, the report is saved with the database type that was set
    in the Designer.
    3. When opened, the database type is not assigned anywhere; instead, it
    is loaded from the RTM file.

    And if this is correct, I now see why my reports all use DatabaseType =
    dtOther, as the reports' templates do not contain this property.

    My only concern with this is the following: saving the database type in
    the report makes the report work in only one database type. If you
    move the report templates to another database, you have to replace the
    DatabaseType in all your templates. For example, we are currently
    running the reports in NexusDB3 using dakbmMW connected to the NexusDB
    Server. We are planning to start testing the reports in SQL Server
    using dakbmMW connected to MSSQL using Zeos. So the DatabaseType
    stored in the RTM files is going to be a problem.

    I guess I'll continue setting the SQL.DatabaseType property in the
    SQLChanged method of the data view, based on the current kbmMW adapter
    being used. Do you think I'll run into problems using this approach?

    Thanks in advance!

    Using RB12.04 Build 77
  • edited June 2011
    Hi Arturo,

    I believe the reason the DatabaseType was not saved down in your
    templates is that dtOther is the default value for the property.

    The report templates are not designed to be used with multiple database
    types. Simply changing the DatabaseType will not allow them to be
    automatically used with a different database. The DADE dataview classes
    would also all need to be changed (at a minimum). See the following
    article on converting templates.



    Nico Cizik
    Digital Metaphors

    Best Regards,

    Nico Cizik
    Digital Metaphors
  • edited June 2011
    Hi, Nico!

    Thanks for the information. I went through this process when going from
    FlashFiler to NexusDB, and then from NexusDB to kbmMW. With kbmMW,
    however, I'm looking to eliminate this problem: I use the same DataView
    class, and it is the adapter of kbmMW that handles the connection to
    the database type we choose. In this way, I don't need to change the
    reports if I switch databases; I just need to use a different adapter
    for kbmMW. I'm currently migrating our apps to a middleware framework,
    and after doing this, I plan to offer one version of our software for
    Nexus and another for MSSQL using the same code base.

    And this is why changing the database type becomes important, as it
    defines the SQL used when generating the reports. However, since right
    now it is being stored in the report, I'm going to use a function that
    I have to pre-process the report in Text format (I use it to translate
    our reports at run-time from English to other languages) and in that
    method, modify the database type. Since this is done before loading, I
    should be able to have the SQL I need depending on the kbmMW adapter
    I'm using at the moment.

    Thanks again!

    Using RB12.04 Build 77
This discussion has been closed.