Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

RAP code error when modifying daSQL query

edited May 2004 in End User
Hello again. I am modifying the TdaSQL.SQLText for my report. However, only
whenever I modify the SQLText for the report, I receive an error in my RAP
code:

1) Invalid variant type conversion
2) ECodeError: Could not run program Label6OnPrint.

The Label6OnPrint RAP procedure contains the following:

Label6.Caption := Employee_Certifications['Last Name'] + ', ' +
Employee_Certifications['First Name'];

It works fine as long as I don't issue the "TdaSQL.EditSQLAsText" code.
Even if I don't even modify the SQLText property after issing the
EditSQLAsText code, I still receive the error.

Thanks in advance.

Brian Kennedy
RB Ent 7.03

Comments

  • edited May 2004

    Try calling TdaQueryDataView.OutOfSync after setting the EditSQLAsText
    property.


    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2004
    Nard,

    I did as you said and receive the same results. Below is my code snipet. I
    actually had "OutOfSync" already, but it was located after the SQLText
    assignment.

    aSQL.EditSQLAsText := True;
    lDataView.OutOfSync;
    aSQL.SQLText.Text := strCustomSQL;

    What else can I try? Thank you.

    Brian Kennedy

  • edited May 2004

    I researched this and the TdaSQL object requires that you assign a TStrings
    object to the SQLText property. Try soemthing like this....

    var
    lSQLText: TStringList;


    lSQLText := TStringList.Create;
    lSQLText.Text := 'Select * from customer.db';

    lSQL.SQLText := lSQLText;

    lSQLText.Free;



    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2004
    Nard,

    I did as you said and still get the same results. Below is the code snipet.
    Even if I don't assign the "SQLText", the error still occurs. All I have to
    do is issue the "aSQL.EditSQLAsText=True" and that creates the problem all
    by itself. I have traced the problem to that line of code by commenting the
    others out. Thanks in advance.

    lSQLText := TStringList.Create;
    aSQL.EditSQLAsText := True; (<-- As a test, I commented out each line
    after this and the problem still occurred)
    lDataView.OutOfSync;
    lSQLText.Text := strCustomSQL;
    aSQL.SQLText := lSQLText;
    lSQLText.Free;


    Brian Kennedy
    RB Ent 7.03

  • edited May 2004

    Try the exact code that I posted in my prior response. Do not add any
    additional code. Notice that I do not set EditSQLAsText to true. (This will
    occur automatically. ) I also do not call out of sync.



    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited May 2004
    Nard,

    I still receive the same results. But, I did find this out. If I write my
    RAP code for the actual field names instead of the aliases, it works. Does
    that help?

    This is what I had previously which DID NOT work only when I modified the
    TdaSQL. When I didn't modify the TdaSQL, it worked fine:

    Label6.Caption := Employee_Certifications['Last Name'] + ', ' +
    Employee_Certifications['First Name'];

    This is what I have now which represents the actual field names instead of
    aliases.

    Label6.Caption := Employee_Certifications['Last'] + ', ' +
    Employee_Certifications['First'];

    Any ideas why the aliases don't work when you modify the TdaSQL.SQLText?

    Thanks in advance.

    Brian Kennedy
    RB 7.03

  • edited May 2004

    When you use the Query tools do you have the app configured to use the
    DataDictionary? If so then the Query tools use the DataDictionary to
    generate the field aliases. The DataDictionary will not be used if you
    assign SQL text.

    When you specify the SQL text, the SQL text will be assigned to the
    QueryDataView which contains a TDataSet descendant (i.e. TQuery if you using
    BDE) and the DataSet will create TField objects for the SQL result set. The
    QueryDataView will use the TField objects to create TppField objects for the
    DBPipeline.


    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.