Sign in Join
Wiki copytemporary

TSQLQuery: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: TSQLQuery

OldNewLine
1+**TSQLQuery** ![](/wiki-images/b/bb/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]].
2+
3+Typical use of a TSQLQuery:
4+
5+` SQLTransaction1.Database := SQLConnection1;`\
6+` SQLQuery1.Transaction := SQLTransaction1;`\
7+` DataSource1.DataSet := `**`SQLQuery1`**`;`\
8+` DBGrid1.DataSource := DataSource1;`
9+
10+### Select
11+
12+Select all columns from table somelist:
13+
14+``` pascal
15+ SQLQuery1.SQL.Text := 'SELECT * FROM somelist';
16+ SQLQuery1.Open();
17+```
18+
19+### Insert
20+
21+Insert a new record into table somelist:
22+
23+``` pascal
24+ SQLQuery1.SQL.Text := 'INSERT INTO somelist (ItemNr,ItemCount) VALUES (1231,2)';
25+ SQLQuery1.ExecSQL();
26+ SQLTransaction1.Commit();
27+```
28+
29+## See also
30+
31+- [TSQLQuery doc](http://www.freepascal.org/docs-html/fcl/sqldb/tsqlquery.html)
32+- [Using SQLdb](http://www.freepascal.org/docs-html/fcl/sqldb/usingsqldb.html)
33+
34+---
35+*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).*

Back to history