Page 1 of 1

Potential bug in TMyQuery.GetFieldEnum

Posted: Sat 01 Dec 2012 17:02
by onnodb
I'm currently running into the following problem with MyDAC 7.5.10 for RAD Studio 2007 (Delphi 2007):
  • I have a TMyQuery on a form, with its SQL property set to "SELECT * FROM OtherDatabase.MyTable".
  • The TMyQuery is linked to a TMyConnection that's connected to the "FirstDatabase" database.
  • In my code, I try to call TMyQuery.GetFieldEnum, to find the possible values of a field "MyTable.Field" (where MyTable is in *OtherDatabase*!).
The code crashes, with an exception that indicates that MyDAC is internally searching for the field "FirstDatabase.Field", instead of "OtherDatabase.Field".

I'm fairly sure that this is a regression that was introduced between October 2010 and June 2012.

Thanks in advance!


Onno

Re: Potential bug in TMyQuery.GetFieldEnum

Posted: Mon 03 Dec 2012 09:37
by AndreyZ
Hello,

To avoid the problem, you should specify the full table name in the TableName parameter of the GetFieldEnum method. Here is a code example:

Code: Select all

MyQuery1.SQL.Text := 'select * from databasename.tablename';
MyQuery1.Open;
MyQuery1.GetFieldEnum(Memo1.Lines, 'fieldname', '`databasename`.`tablename`');

Re: Potential bug in TMyQuery.GetFieldEnum

Posted: Mon 03 Dec 2012 19:30
by onnodb
Ah, thanks a lot; that's a perfect workaround! I already tried without the backticks, which didn't work, but prefixing with the database name does solve the problem when you also add explicit backticks.

Thanks again, also for the speed of the reply!

Re: Potential bug in TMyQuery.GetFieldEnum

Posted: Tue 04 Dec 2012 09:48
by AndreyZ
I am glad I could help. Feel free to contact us if you have any other questions about MyDAC.