TSQLQuery: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | **TSQLQuery**  is a fundamental database query component for use with any supported database. The component is found on [[SQLdb tab]] of the [[Component Palette]]. | |
| 2 | 2 | ||
| 3 | 3 | Typical use of a TSQLQuery: | |
| 4 | 4 | ||
| 5 | - | ||
| 6 | - | ||
| 7 | - | ||
| 8 | - | ||
| 5 | + | ``` pascal | |
| 6 | + | SQLTransaction1.Database := SQLConnection1; | |
| 7 | + | SQLQuery1.Transaction := SQLTransaction1; | |
| 8 | + | DataSource1.DataSet := SQLQuery1; | |
| 9 | + | DBGrid1.DataSource := DataSource1; | |
| 10 | + | ``` | |
| 9 | 11 | ||
| 10 | 12 | ### Select | |
| 11 | 13 | ||
| 12 | 14 | Select all columns from table somelist: | |
| 13 | 15 | ||
| 14 | 16 | ``` pascal | |
| 15 | 17 | SQLQuery1.SQL.Text := 'SELECT * FROM somelist'; | |
| 16 | 18 | SQLQuery1.Open(); | |
| 17 | 19 | ``` | |
| 18 | 20 | ||
| 19 | 21 | ### Insert | |
| 20 | 22 | ||
| 21 | 23 | Insert a new record into table somelist: | |
| 22 | 24 | ||
| 23 | 25 | ``` pascal | |
| 24 | 26 | SQLQuery1.SQL.Text := 'INSERT INTO somelist (ItemNr,ItemCount) VALUES (1231,2)'; | |
| 25 | 27 | SQLQuery1.ExecSQL(); | |
| 26 | 28 | SQLTransaction1.Commit(); | |
| 27 | 29 | ``` | |
| 28 | 30 | ||
| 29 | 31 | ## See also | |
| 30 | 32 | ||
| 31 | 33 | - [TSQLQuery doc](http://www.freepascal.org/docs-html/fcl/sqldb/tsqlquery.html) | |
| 32 | 34 | - [Using SQLdb](http://www.freepascal.org/docs-html/fcl/sqldb/usingsqldb.html) | |
| 33 | 35 | ||
| 34 | 36 | --- | |
| 35 | 37 | *From the Free Pascal wiki, page "TSQLQuery", as it stood on 2024-03-26 after a change by Ariben, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
