Difference between revisions of "TDBGrid"
From Free Pascal wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
'''TDBGrid''' [[image:tdbgrid.png]] is a visual component that displays tabular data from database contents through means of a [[TDataSet]] derivative like a [[TSQLQuery]]. The TDBGrid component is available from the [[Data Controls tab]] of the [[Component Palette]]. | '''TDBGrid''' [[image:tdbgrid.png]] is a visual component that displays tabular data from database contents through means of a [[TDataSet]] derivative like a [[TSQLQuery]]. The TDBGrid component is available from the [[Data Controls tab]] of the [[Component Palette]]. | ||
− | SQLTransaction1.Database := | + | SQLTransaction1.Database := SQLConnector1; |
SQLQuery1.Transaction := SQLTransaction1; | SQLQuery1.Transaction := SQLTransaction1; | ||
DataSource1.DataSet := SQLQuery1; | DataSource1.DataSet := SQLQuery1; | ||
'''DBGrid1'''.DataSource := DataSource1; | '''DBGrid1'''.DataSource := DataSource1; | ||
+ | |||
+ | SQLConnector1.ConnectorType := 'MySQL 5.7'; | ||
+ | SQLConnector1.HostName := 'MyServer'; | ||
+ | SQLConnector1.DatabaseName := 'MyDBName'; | ||
+ | SQLConnector1.UserName := 'MyName'; | ||
+ | SQLConnector1.Password := 'MyPass'; | ||
+ | |||
SQLQuery1.SQL := 'SELECT * FROM Table1'; | SQLQuery1.SQL := 'SELECT * FROM Table1'; | ||
'''DBGrid1'''.Columns[0].Title.Caption := 'Col1'; | '''DBGrid1'''.Columns[0].Title.Caption := 'Col1'; |
Revision as of 00:02, 6 August 2016
TDBGrid is a visual component that displays tabular data from database contents through means of a TDataSet derivative like a TSQLQuery. The TDBGrid component is available from the Data Controls tab of the Component Palette.
SQLTransaction1.Database := SQLConnector1; SQLQuery1.Transaction := SQLTransaction1; DataSource1.DataSet := SQLQuery1; DBGrid1.DataSource := DataSource1; SQLConnector1.ConnectorType := 'MySQL 5.7'; SQLConnector1.HostName := 'MyServer'; SQLConnector1.DatabaseName := 'MyDBName'; SQLConnector1.UserName := 'MyName'; SQLConnector1.Password := 'MyPass'; SQLQuery1.SQL := 'SELECT * FROM Table1'; DBGrid1.Columns[0].Title.Caption := 'Col1'; DBGrid1.Columns[0].FieldName := 'Field1'; SQLQuery1.Open();
Freepascal Documentation