hidrau
asked on
Is there any function that it could return me the datatype name of the field in string?
Hy
I use delphi 5 and I'd like to know if there is a function that can return the datetype of my field in string that I could display in a memoedit.
thanks
Alex
I use delphi 5 and I'd like to know if there is a function that can return the datetype of my field in string that I could display in a memoedit.
thanks
Alex
ASKER
When I open a query in an adoquery and I load the columns I want to display in memoedit all the fields name e its datatype:
something like this:
field = product datatype = ftstring size = 30
the fieldname and size I was able to inform, but datatype not.
The only way I found is that:
if Qexcel.FieldByName(AFieldN ame).DataT ype = ftDateTime Then str := 'ftDateTime '
if Qexcel.FieldByName(AFieldN ame).DataT ype = ftFloat Then str := 'ftFloat'
I need to compare with exited datatypes
something like this:
field = product datatype = ftstring size = 30
the fieldname and size I was able to inform, but datatype not.
The only way I found is that:
if Qexcel.FieldByName(AFieldN
if Qexcel.FieldByName(AFieldN
I need to compare with exited datatypes
ASKER
Hi,
I got it :))
this was what I would like
function TFListCotImporta.TipoField (campo: String): String;
const
cmp : array[0..37] of string = ('ftUnknown', 'ftString', 'ftSmallint', 'ftInteger', 'ftWord', 'ftBoolean', 'ftFloat', 'ftCurrency', 'ftBCD', 'ftDate', 'ftTime', 'ftDateTime', 'ftBytes',
'ftVarBytes', 'ftAutoInc', 'ftBlob', 'ftMemo', 'ftGraphic', 'ftFmtMemo', 'ftParadoxOle', 'ftDBaseOle', 'ftTypedBinary', 'ftCursor', 'ftFixedChar', 'ftWideString',
'ftLargeint', 'ftADT', 'ftArray', 'ftReference', 'ftDataSet', 'ftOraBlob', 'ftOraClob', 'ftVariant', 'ftInterface', 'ftIDispatch', 'ftGuid', 'ftTimeStamp', 'ftFMTBcd');
var
x : variant;
begin
x := TFieldType(Adoquery.FieldB yName(camp o).DataTyp e);
showMessage(cmp[StrToInt(x )])
end;
I got it :))
this was what I would like
function TFListCotImporta.TipoField
const
cmp : array[0..37] of string = ('ftUnknown', 'ftString', 'ftSmallint', 'ftInteger', 'ftWord', 'ftBoolean', 'ftFloat', 'ftCurrency', 'ftBCD', 'ftDate', 'ftTime', 'ftDateTime', 'ftBytes',
'ftVarBytes', 'ftAutoInc', 'ftBlob', 'ftMemo', 'ftGraphic', 'ftFmtMemo', 'ftParadoxOle', 'ftDBaseOle', 'ftTypedBinary', 'ftCursor', 'ftFixedChar', 'ftWideString',
'ftLargeint', 'ftADT', 'ftArray', 'ftReference', 'ftDataSet', 'ftOraBlob', 'ftOraClob', 'ftVariant', 'ftInterface', 'ftIDispatch', 'ftGuid', 'ftTimeStamp', 'ftFMTBcd');
var
x : variant;
begin
x := TFieldType(Adoquery.FieldB
showMessage(cmp[StrToInt(x
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I forgot to mention that this technique of course works with ALL enumerated types, even your own, and does not require that you manually maintain another table of string constants for each and everyone of those enums types where you would need to get their value to string equivalent
Delphi do it for you. Which is precisely why I said Delphi is wonderful :o).
Did I said how great Delphi's RTTI (Run-Time Type Information) system is ?
Delphi do it for you. Which is precisely why I said Delphi is wonderful :o).
Did I said how great Delphi's RTTI (Run-Time Type Information) system is ?
ASKER
thanks
Usually there is a way to get the information from a database, assuming you have sufficient permissions to allow you to do so.
As for the Data File, that sort of depends on the data file and the manner in which you are accessing it.
Other than that, the general IT answer, as always, is going to be, "It depends."