Page 1 of 1

TFieldType problem

Posted: Sat 26 Jul 2008 13:43
by kaffeburk
I'm trying to clone a database into a TVirtualTable. Im using 3 methods from the TmyQuery:

(1) GetFieldNames (works fine)
(2) GetDataType (works randomly)
(3) GetFieldPrecision (works randomly)

The later 2 methods don't seem to work, are they implemented in Mydac? If not i guess i have to extract them myself from Mysql using paramtext....

Posted: Thu 31 Jul 2008 12:13
by Dimon
In order to learn the field datatype you can use the TFieldDef.DataType property.
To learn the field precision, you can use the TFieldDef.Precision property.

Posted: Mon 04 Aug 2008 13:07
by kaffeburk
Dimon wrote:In order to learn the field datatype you can use the TFieldDef.DataType property.
To learn the field precision, you can use the TFieldDef.Precision property.
I cant find any such property. Where can i find the TFieldDef ? Its not a member of TMyQuery...

Posted: Tue 05 Aug 2008 11:26
by Dimon
To get access to the field definitions list for a dataset you can use the TDataSet.FieldDefs property or TDataSet.FieldDefList.

Posted: Tue 05 Aug 2008 13:43
by kaffeburk
Dimon wrote:To get access to the field definitions list for a dataset you can use the TDataSet.FieldDefs property or TDataSet.FieldDefList.
Sorry, i cant find that either. Can you please provide an code example?

Posted: Tue 05 Aug 2008 15:19
by kaffeburk
Ah, think i got it:

dbFtype:= qry_getinfo.FieldDefs[0].DataType;

Thanx!

Posted: Tue 05 Aug 2008 16:03
by kaffeburk
Neither FieldDefs or FieldDefList provides the precision for VARCHAR, the result is always 0.

FieldDefs[].Name does work. I guess i'm back to query MySql directly...

Posted: Wed 06 Aug 2008 11:17
by Dimon
The Precision property defines the total number of digits stored in numeric fields. To get the length of string field you should use the TFieldDef.Size property.

Posted: Wed 06 Aug 2008 13:27
by kaffeburk
Dimon wrote:The Precision property defines the total number of digits stored in numeric fields. To get the length of string field you should use the TFieldDef.Size property.
What i am looking for is the maximum precision as the database was defined in mysql. If i have a column created as VARCHAR(60) i want to retrieve the 60.

Posted: Thu 07 Aug 2008 13:28
by jkuiper
use this:

Code: Select all

virtualtable.Assign(MyQuery)
. Works for me.

Posted: Fri 08 Aug 2008 06:18
by Dimon
In order to get 60 for the VARCHAR(60) field you should use the TFieldDef.Size property.
The Precision property defines the total number of digits stored in NUMERIC! fields.

Posted: Fri 08 Aug 2008 09:03
by kaffeburk
jkuiper wrote:use this:

Code: Select all

virtualtable.Assign(MyQuery)
. Works for me.
Thanx, i missed that procedure. ... Spending a week wrinting my own assign...

Is there any way to add another MyQuery? I need to add mutiple assigns to my virtualtable.

Posted: Fri 08 Aug 2008 09:59
by jkuiper
Do you mean adding another Myquery with the same structure after assigned the first dataset? I don't think so. Then its better to use TBatchmove.
If you want to use Myquery with another structure with the same virtualtable, it's possible.
The best thing to do that

Code: Select all

VirtualTable.DeleteFields;
Virtualtable.Assign(Myquery);
The stranges thing is that dimon could no the answere, because he could find it here http://devart.com/forums/viewtopic.php?t=107

I'm glad I could help you
:wink: