Get the fieldtypes of a dataset lazarus / 16-Databases ---------------------------------------------------------------------- Hansvb · 2016-02-20 17:00 How to extract the fieldtypes  of a dataset? I tried this but that gives an error Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i mystring := Active_DBGrid.DataSource.DataSet.Fields[i].DataType;  //mystring is a string variable the error  : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Incompatible types: got "TFieldType" expected "AnsiString" So how can i convert the Fieldtype to String? ---------------------------------------------------------------------- howardpc · 2016-02-20 18:03 Try this function: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses db, typinfo; function FieldTypeAsString(aFieldType: TFieldType): string;begin  Result:=GetEnumName(TypeInfo(TFieldType), Ord(aFieldType));end; ---------------------------------------------------------------------- itmitica · 2016-02-20 18:44 You don't. You create a TFieldType variable and then you look the value up in the TFieldType enumerated set. Above you got the exemplification. Below there are some explanations about enumerated sets. http://lazarus-ccr.sourceforge.net/docs/fcl/db/tfieldtype.html Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses   db, // using db adds the TFieldType type to the environment  typinfo; // using typinfo adds the GetEnumType function to the environment var  ft: TFieldType;  // you could also declare a set sft: set of TFieldType; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // ft := Active_DBGrid.DataSource.DataSet.Fields[i].DataType;ft := ftString;// sft := [ftUnknown, ftString, ftInteger]; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // if Ord(TFieldType.ftUnknown) = 0 // trueif Ord(ft) = 1 //true Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // if GetEnumName( TypeInfo(TFieldType), 0 ) = ftUnknown // trueif GetEnumName( TypeInfo(TFieldType), Ord(ft) ) = ftString // true ---------------------------------------------------------------------- Hansvb · 2016-02-20 20:25 Thanks. I used the solution from Howardpc. It works. ---------------------------------------------------------------------- LacaK · 2016-02-23 17:13 Quote from: Hansvb on February 20, 2016, 06:00:18 pmSo how can i convert the Fieldtype to String? There is array FieldTypeNames. Usage: FieldTypeNames[Fields.DataType]