?? showstruct.pas
字號:
unit ShowStruct;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids,DB,XADOEX, ComCtrls;
type
TTableStructForm = class(TForm)
StructGrid: TStringGrid;
StatusBar1: TStatusBar;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
TableStructForm: TTableStructForm;
tablename:string;
function GetFieldtype(fieldtype:TFieldType):string;
implementation
uses MainUnit;
{$R *.dfm}
procedure TTableStructForm.FormShow(Sender: TObject);
begin
self.caption:=tablename;
X_GetStruct(SQLBrowseManager.ADOConnection,StructGrid,tablename);
statusbar1.Panels[0].Text:='共有 '+inttostr(StructGrid.RowCount-1)+' 個字段';
{
StructGrid.cells[0,0]:='序號';
StructGrid.cells[1,0]:='字段名';
StructGrid.cells[2,0]:='字段類型';
StructGrid.cells[3,0]:='字段寬度';
StructGrid.cells[4,0]:='是否為主鍵';
try
SQLBrowseManager.ADOConnection.close;
SQLBrowseManager.ADOConnection.sql.clear;
SQLBrowseManager.ADOQuery.sql.add('select top 1 * from '+tablename);
SQLBrowseManager.ADOQuery.open;
StructGrid.rowcount:=SQLBrowseManager.ADOQuery.fieldcount+1;
for i:=1 to structGrid.rowcount-1 do
begin
structGrid.cells[0,i]:=inttostr(i);
structGrid.cells[1,i]:=SQLBrowseManager.ADOQuery.fields[i-1].FieldName;
structGrid.cells[2,i]:=GetFieldtype(SQLBrowseManager.ADOQuery.Fields[i-1].DataType);
structGrid.cells[3,i]:=inttostr(SQLBrowseManager.ADOQuery.Fields[i-1].DataSize);
end;
finally
SQLBrowseManager.ADOQuery.close;
end; }
end;
function GetFieldtype(fieldtype:TFieldType):string;
begin
case fieldtype of
ftUnknown:result:='';
ftString:result:='';
ftSmallint:result:='';
ftInteger:result:='';
ftWord:result:='';
ftBoolean:result:='';
ftFloat:result:='';
ftCurrency:result:='';
ftBCD:result:='';
ftDate:result:='';
ftTime:result:='';
ftDateTime:result:='';
ftBytes :result:='';
ftVarBytes:result:='';
ftAutoInc :result:='';
ftBlob :result:='';
ftMemo :result:='';
ftGraphic :result:='';
ftFmtMemo :result:='';
ftParadoxOle :result:='';
ftDBaseOle:result:='';
ftTypedBinary :result:='';
ftCursor :result:='';
ftFixedChar :result:='';
ftWideString :result:='String';
ftLargeint :result:='';
ftADT :result:='';
ftArray :result:='';
ftReference:result:='';
ftDataSet :result:='';
ftOraBlob :result:='';
ftOraClob :result:='';
ftVariant :result:='';
ftInterface :result:='';
ftIDispatch :result:='';
ftGuid :result:='';
ftTimeStamp :result:='';
ftFMTBcd :result:='';
end;
end;
procedure TTableStructForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action:=caFree;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -