Sql Server 2005以上であれば、システムカタログに対してクエリを発行することで
テーブル名とフィールド名のリストの取得ができます。
(詳細は、システムカタログのクエリのQandAページを参照)
クエリを発行できるということは、
程度の画面であればマスターリンクを使ってノンコーディング
(クエリーは組む必要はありますが)でテーブルとフィールドのリストを表示できます。
このへんがDelphiのすごいところですね。
以下、フォーム表示をテキスト表示したもの
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 535
ClientWidth = 727
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object PageControl1: TPageControl
Left = 0
Top = 0
Width = 727
Height = 535
ActivePage = TabSheet2
Align = alClient
TabOrder = 0
object TabSheet1: TTabSheet
Caption = 'TabSheet1'
object Label1: TLabel
Left = 192
Top = 88
Width = 56
Height = 13
Caption = #12501#12451#12540#12523#12489#21517
end
object Label2: TLabel
Left = 16
Top = 88
Width = 50
Height = 13
Caption = #12486#12540#12502#12523#21517
end
object Label3: TLabel
Left = 552
Top = 88
Width = 56
Height = 13
Caption = #12501#12451#12540#12523#12489#21517
end
object Label4: TLabel
Left = 376
Top = 88
Width = 50
Height = 13
Caption = #12486#12540#12502#12523#21517
end
object Button1: TButton
Left = 96
Top = 16
Width = 169
Height = 33
Caption = 'dbGo'#12398#12513#12477#12483#12489#12434#20351#29992
TabOrder = 0
OnClick = Button1Click
end
object ListBox1: TListBox
Left = 16
Top = 106
Width = 169
Height = 401
ItemHeight = 13
TabOrder = 1
OnClick = ListBox1Click
end
object ListBox2: TListBox
Left = 191
Top = 106
Width = 169
Height = 401
ItemHeight = 13
TabOrder = 2
end
object ListBox3: TListBox
Left = 376
Top = 106
Width = 169
Height = 401
ItemHeight = 13
TabOrder = 3
OnClick = ListBox3Click
end
object ListBox4: TListBox
Left = 550
Top = 106
Width = 169
Height = 401
ItemHeight = 13
TabOrder = 4
end
object Button2: TButton
Left = 472
Top = 16
Width = 169
Height = 33
Caption = 'DbExpress'#12398#12513#12477#12483#12489#12434#20351#29992
TabOrder = 5
OnClick = Button2Click
end
end
object TabSheet2: TTabSheet
Caption = 'TabSheet2'
ImageIndex = 1
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 145
Height = 507
Align = alLeft
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'Name'
Visible = True
end>
end
object DBGrid2: TDBGrid
Left = 145
Top = 0
Width = 160
Height = 507
Align = alLeft
DataSource = DataSource2
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'NAME'
Visible = True
end>
end
end
object TabSheet3: TTabSheet
Caption = 'TabSheet3'
ImageIndex = 2
object DBGrid3: TDBGrid
Left = 0
Top = 0
Width = 177
Height = 507
Align = alLeft
DataSource = DataSource3
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'Name'
Visible = True
end>
end
object DBGrid4: TDBGrid
Left = 177
Top = 0
Width = 184
Height = 507
Align = alLeft
DataSource = DataSource4
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'NAME'
Visible = True
end>
end
end
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=SQLNCLI10.1;Integrated Security="";Persist Security Inf' +
'o=False;User ID=sa;Initial Catalog=AdventureWorks;Data Source=SA' +
'KANOTE-PC\SqlExpress;Initial File Name="";Server SPN=""'
LoginPrompt = False
Provider = 'SQLNCLI10.1'
Left = 16
Top = 456
end
object SQLConnection1: TSQLConnection
ConnectionName = 'MSSQLConnection'
DriverName = 'MSSQL'
GetDriverFunc = 'getSQLDriverMSSQL'
LibraryName = 'dbxmss.dll'
LoginPrompt = False
Params.Strings = (
'SchemaOverride=%.dbo'
'DriverUnit=DBXMSSQL'
'DriverPackageLoader=TDBXDynalinkDriverLoader,DBXCommonDriver150.' +
'bpl'
'DriverAssemblyLoader=Borland.Data.TDBXDynalinkDriverLoader,Borla' +
'nd.Data.DbxCommonDriver,Version=15.0.0.0,Culture=neutral,PublicK' +
'eyToken=91d62ebb5b0d1b1b'
'MetaDataPackageLoader=TDBXMsSqlMetaDataCommandFactory,DbxMSSQLDr' +
'iver150.bpl'
'MetaDataAssemblyLoader=Borland.Data.TDBXMsSqlMetaDataCommandFact' +
'ory,Borland.Data.DbxMSSQLDriver,Version=15.0.0.0,Culture=neutral' +
',PublicKeyToken=91d62ebb5b0d1b1b'
'GetDriverFunc=getSQLDriverMSSQL'
'LibraryName=dbxmss.dll'
'VendorLib=sqlncli10.dll'
'MaxBlobSize=-1'
'OSAuthentication=False'
'PrepareSQL=True'
'DriverName=MSSQL'
'HostName=SAKANOTE-PC\SQLEXPRESS'
'Database=AdventureWorks'
'User_Name=sa'
'Password=sysdba'
'BlobSize=-1'
'ErrorResourceFile='
'LocaleCode=0000'
'IsolationLevel=ReadCommitted'
'OS Authentication=False'
'Prepare SQL=False'
'ConnectTimeout=60'
'Mars_Connection=False')
VendorLib = 'sqlncli10.dll'
Connected = True
Left = 464
Top = 56
end
object ADOQuery1: TADOQuery
Connection = ADOConnection1
CursorType = ctStatic
Parameters = <>
SQL.Strings = (
'SELECT Object_ID, Name FROM SYS.TABLES')
Left = 16
Top = 488
end
object DataSetProvider1: TDataSetProvider
DataSet = ADOQuery1
Left = 56
Top = 504
end
object ClientDataSet1: TClientDataSet
Active = True
Aggregates = <>
Params = <>
ProviderName = 'DataSetProvider1'
Left = 88
Top = 504
end
object DataSource1: TDataSource
DataSet = ClientDataSet1
Left = 24
Top = 184
end
object ADOQuery2: TADOQuery
Connection = ADOConnection1
CursorType = ctStatic
Parameters = <
item
Name = 'Object_ID'
DataType = ftInteger
Value = 14623095
end>
SQL.Strings = (
'SELECT Object_ID , NAME FROM sys.columns')
Left = 144
Top = 504
end
object ClientDataSet2: TClientDataSet
Active = True
Aggregates = <>
IndexFieldNames = 'Object_ID'
MasterFields = 'Object_ID'
MasterSource = DataSource1
PacketRecords = 0
Params = <>
ProviderName = 'DataSetProvider2'
Left = 208
Top = 504
end
object DataSetProvider2: TDataSetProvider
DataSet = ADOQuery2
Left = 176
Top = 504
end
object DataSource2: TDataSource
DataSet = ClientDataSet2
Left = 96
Top = 176
end
object ClientDataSet3: TClientDataSet
Active = True
Aggregates = <>
Params = <>
ProviderName = 'DataSetProvider3'
Left = 464
Top = 112
end
object DataSetProvider3: TDataSetProvider
DataSet = SQLQuery1
Left = 464
Top = 168
end
object SQLQuery1: TSQLQuery
MaxBlobSize = -1
Params = <>
SQL.Strings = (
'SELECT Object_ID, Name FROM SYS.TABLES')
SQLConnection = SQLConnection1
Left = 464
Top = 216
end
object DataSource3: TDataSource
DataSet = ClientDataSet3
Left = 456
Top = 280
end
object DataSetProvider4: TDataSetProvider
DataSet = SQLQuery2
Left = 600
Top = 176
end
object ClientDataSet4: TClientDataSet
Active = True
Aggregates = <>
IndexFieldNames = 'Object_ID'
MasterFields = 'Object_ID'
MasterSource = DataSource3
PacketRecords = 0
Params = <>
ProviderName = 'DataSetProvider4'
Left = 592
Top = 104
end
object DataSource4: TDataSource
DataSet = ClientDataSet4
Left = 576
Top = 280
end
object SQLQuery2: TSQLQuery
MaxBlobSize = -1
Params = <
item
DataType = ftInteger
Name = 'Object_ID'
ParamType = ptInput
Value = 14623095
end>
SQL.Strings = (
'SELECT Object_ID , NAME FROM sys.columns')
SQLConnection = SQLConnection1
Left = 584
Top = 240
end
end
0 件のコメント:
コメントを投稿