TIPO DE DADOS DE UM CAMPO

Delphi

23/06/2003

Preciso colocar o tipo de dado de um campo em uma variável String como faço.

Por exemplo tenho uma tabela em Paradox com alguns campos. Preciso saber o tipo de dados de cada campo.

Table1.Fields[0].DataType

Mas preciso colocar o tipo de cada campo em uma variável string.

COMO FAÇO.


Ricardo Barbosa

Ricardo Barbosa

Curtidas 0

Respostas

Cdaraujo

Cdaraujo

23/06/2003

Caro amigo,
Veja um exemplo que implementei para vc
Atenciosamente,

Daniel Araújo

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables;

type

TForm1 = class(TForm)
Table1: TTable;
Table1LAST_NAME: TStringField;
Table1FIRST_NAME: TStringField;
Table1ACCT_NBR: TFloatField;
Table1ADDRESS_1: TStringField;
Table1CITY: TStringField;
Table1STATE: TStringField;
Table1ZIP: TStringField;
Table1TELEPHONE: TStringField;
Table1DATE_OPEN: TDateField;
Table1SS_NUMBER: TFloatField;
Table1PICTURE: TStringField;
Table1BIRTH_DATE: TDateField;
Table1RISK_LEVEL: TStringField;
Table1OCCUPATION: TStringField;
Table1OBJECTIVES: TStringField;
Table1INTERESTS: TStringField;
Table1IMAGE: TBlobField;
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
sTypes: 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´);


implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
I:Integer;
begin
ListBox1.Clear;
for I:=0 to Table1.Fields.Count -1 do
ListBox1.Items.Add(´Nome:´ + Table1.Fields[I].FieldName +
´ Tipo: ´ + sTypes[Ord(Table1.Fields[I].DataType)] );
end;

end.

[quote:88166ceb81=´Ricardo Antunes Barbosa´]Preciso colocar o tipo de dado de um campo em uma variável String como faço.

Por exemplo tenho uma tabela em Paradox com alguns campos. Preciso saber o tipo de dados de cada campo.

Table1.Fields[0].DataType

Mas preciso colocar o tipo de cada campo em uma variável string.

COMO FAÇO.[/quote:88166ceb81]


GOSTEI 0
POSTAR