Difference between revisions of "TSQLQuery"
From Free Pascal wiki
Jump to navigationJump to searchGeoffState (talk | contribs) (→Select) |
m (Fixed syntax highlighting) |
||
Line 1: | Line 1: | ||
{{TSQLQuery}} | {{TSQLQuery}} | ||
{{Infobox databases}} | {{Infobox databases}} | ||
+ | |||
'''TSQLQuery''' [[image:tsqlquery.png]] is a fundamental database query component for use with any supported database. The component is found on [[SQLdb tab]] of the [[Component Palette]]. | '''TSQLQuery''' [[image:tsqlquery.png]] is a fundamental database query component for use with any supported database. The component is found on [[SQLdb tab]] of the [[Component Palette]]. | ||
Line 10: | Line 11: | ||
===Select=== | ===Select=== | ||
+ | |||
Select all columns from table somelist: | Select all columns from table somelist: | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
SQLQuery1.SQL.Text := 'SELECT * FROM somelist'; | SQLQuery1.SQL.Text := 'SELECT * FROM somelist'; | ||
SQLQuery1.Open(); | SQLQuery1.Open(); | ||
Line 17: | Line 20: | ||
===Insert=== | ===Insert=== | ||
+ | |||
Insert a new record into table somelist: | Insert a new record into table somelist: | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
SQLQuery1.SQL.Text := 'INSERT INTO somelist (ItemNr,ItemCount) VALUES (1231,2)'; | SQLQuery1.SQL.Text := 'INSERT INTO somelist (ItemNr,ItemCount) VALUES (1231,2)'; | ||
SQLQuery1.ExecSQL(); | SQLQuery1.ExecSQL(); | ||
Line 25: | Line 30: | ||
==See also== | ==See also== | ||
+ | |||
* [http://www.freepascal.org/docs-html/fcl/sqldb/tsqlquery.html TSQLQuery doc] | * [http://www.freepascal.org/docs-html/fcl/sqldb/tsqlquery.html TSQLQuery doc] | ||
* [http://www.freepascal.org/docs-html/fcl/sqldb/usingsqldb.html Using SQLdb] | * [http://www.freepascal.org/docs-html/fcl/sqldb/usingsqldb.html Using SQLdb] | ||
+ | |||
{{LCL Components}} | {{LCL Components}} |
Revision as of 02:36, 2 March 2020
│
English (en) │
français (fr) │
日本語 (ja) │
русский (ru) │
References:
Tutorials/practical articles:
Databases |
TSQLQuery is a fundamental database query component for use with any supported database. The component is found on SQLdb tab of the Component Palette.
Typical use of a TSQLQuery:
SQLTransaction1.Database := SQLConnection1; SQLQuery1.Transaction := SQLTransaction1; DataSource1.DataSet := SQLQuery1; DBGrid1.DataSource := DataSource1;
Select
Select all columns from table somelist:
SQLQuery1.SQL.Text := 'SELECT * FROM somelist';
SQLQuery1.Open();
Insert
Insert a new record into table somelist:
SQLQuery1.SQL.Text := 'INSERT INTO somelist (ItemNr,ItemCount) VALUES (1231,2)';
SQLQuery1.ExecSQL();
SQLTransaction1.Commit();
See also