Sign in Join
Wiki copytemporary

SQLdb Package: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-The SQLdb package contains FPC units to access a number of SQL databases. It is "packaged" as sqldblaz.lpk in Lazarus, and the components can be found on the [[SQLdb tab]].
1+The SQLdb package contains FPC units to access a number of SQL databases. It is "packaged" as sqldblaz.lpk in Lazarus, and the components can be found on the [[SQLdb tab]].
22
3-![](/wiki-images/c/c5/Sqldbcomponents.png%E2%80%8E)
3+[![sqldbcomponents-n.png](/wiki-images/5/5b/sqldbcomponents-n.png)](</File:sqldbcomponents-n.png>)
44
55## Documentation
66
7-See [SQLDB Documentation](http://www.freepascal.org/docs-html/fcl/sqldb/index.html)
7+See [SQLDB Documentation](<http://www.freepascal.org/docs-html/fcl/sqldb/index.html>)
88
99## Components
1010
11-The SQLdb package provides the following components:
11+The SQLdb package provides the following components:
1212
1313#### TXXXConnection
1414
15-Documentation: see [TSQLConnection documentation](http://www.freepascal.org/docs-html/fcl/sqldb/tsqlconnection.html)
15+Documentation: see [TSQLConnection documentation](<http://www.freepascal.org/docs-html/fcl/sqldb/tsqlconnection.html>)
1616
17-There are various connection components called TXXXConnection, where XXX is the flavour of the database you are connecting to. Each one of these components takes the requests of the SQLQuery and SQLTransaction components and translates them into requests specifically tailored for the database you are using. These connection objects descend from the generic TSQLConnection; you can use TSQLConnection to create database programs that can connect to multiple databases (see [[SQLdb Tutorial3]].
17+There are various connection components called TXXXConnection, where XXX is the flavour of the database you are connecting to. Each one of these components takes the requests of the SQLQuery and SQLTransaction components and translates them into requests specifically tailored for the database you are using. These connection objects descend from the generic TSQLConnection; you can use TSQLConnection to create database programs that can connect to multiple databases (see [[SQLdb Tutorial3]].
1818
19-The actual components are:
19+The actual components are:
2020
21-- TIBConnection ([[Firebird|Borland Interbase / Firebird]])
22-- TMSSQLConnection ([[mssqlconn|Microsoft SQL Server]], available since FPC version 2.6.1/Lazarus 1.0.8)
23-- TMySQL40Connection ([[mysql|MySQL]], requires MySQL 4.0 client library)
24-- TMySQL41Connection ([[mysql|MySQL]], requires MySQL 4.1 client library)
25-- TMySQL50Connection ([[mysql|MySQL]], requires MySQL 5.0 client library)
26-- TMySQL51Connection ([[mysql|MySQL]], requires MySQL 5.1 client library, available since FPC version 2.5.1)
27-- TMySQL55Connection ([[mysql|MySQL]], requires MySQL 5.5 client library, available since FPC version 2.6.1/Lazarus 1.0.8)
28-- TODBCConnection (An ODBC connection to a database that the PC has the driver for; see [[ODBCConn]])
29-- TOracleConnection ([[Lazarus Database Overview|Oracle]])
30-- TPQConnection ([[postgresql|PostgreSQL]])
31-- TSybaseConnection ([[mssqlconn|Sybase ASE]], available since FPC version 2.6.1/Lazarus 1.0.8)
32-- TSQLite3Connection ([[SQLite]], available since FPC version 2.2.2)
33-- TMSSQLConnection ([[mssqlconn|MSSQL]], requires FreeTDS library)
21+ * TIBConnection ([[Firebird|Borland Interbase / Firebird]])
22+ * TMSSQLConnection ([[mssqlconn|Microsoft SQL Server]], available since FPC version 2.6.1/Lazarus 1.0.8)
23+ * TMySQL40Connection ([[mysql|MySQL]], requires MySQL 4.0 client library)
24+ * TMySQL41Connection ([[mysql|MySQL]], requires MySQL 4.1 client library)
25+ * TMySQL50Connection ([[mysql|MySQL]], requires MySQL 5.0 client library)
26+ * TMySQL51Connection ([[mysql|MySQL]], requires MySQL 5.1 client library, available since FPC version 2.5.1)
27+ * TMySQL55Connection ([[mysql|MySQL]], requires MySQL 5.5 client library, available since FPC version 2.6.1/Lazarus 1.0.8)
28+ * TODBCConnection (An ODBC connection to a database that the PC has the driver for; see [[ODBCConn]])
29+ * TOracleConnection ([[Lazarus Database Overview|Oracle]])
30+ * TPQConnection ([[postgresql|PostgreSQL]])
31+ * TSybaseConnection ([[mssqlconn|Sybase ASE]], available since FPC version 2.6.1/Lazarus 1.0.8)
32+ * TSQLite3Connection ([[SQLite]], available since FPC version 2.2.2)
33+ * TMSSQLConnection ([[mssqlconn|MSSQL]], requires FreeTDS library)
3434
3535#### TSQLTransaction
3636
37-Documentation: see [TSQLTransaction documentation](http://www.freepascal.org/docs-html/fcl/sqldb/tsqltransaction.html)
37+Documentation: see [TSQLTransaction documentation](<http://www.freepascal.org/docs-html/fcl/sqldb/tsqltransaction.html>)
3838
39-This encapsulates the transaction on the database server. A TXXXConnection object always needs at least one TSQLTransaction associated with it, so that the transaction of its queries is managed. Queries/actions on the database need to be encapsulated in
39+This encapsulates the transaction on the database server. A TXXXConnection object always needs at least one TSQLTransaction associated with it, so that the transaction of its queries is managed. Queries/actions on the database need to be encapsulated in
4040
41-- a .StartTransaction/.Commit (or .Rollback) block
42-- or a single .StartTransaction at the beginning, followed by .CommitRetaining or .RollBackretaiing. CommitRetaining and RollbackRetaining keep the transaction open, so performing another StartTransaction is not needed.
41+ * a .StartTransaction/.Commit (or .Rollback) block
42+ * or a single .StartTransaction at the beginning, followed by .CommitRetaining or .RollBackretaiing. CommitRetaining and RollbackRetaining keep the transaction open, so performing another StartTransaction is not needed.
4343
44-Setting .Active to true if it was false is equivalent to .StartTransaction.
44+Setting .Active to true if it was false is equivalent to .StartTransaction.
4545
46-Setting .Active to false if it was true is equivalent to .Rollback
46+Setting .Active to false if it was true is equivalent to .Rollback
4747
48+
49+
4850#### TSQLQuery
4951
50-Documentation: see [TSQLQuery](http://www.freepascal.org/docs-html/fcl/sqldb/tsqlquery.html)
52+Documentation: see [TSQLQuery ](<http://www.freepascal.org/docs-html/fcl/sqldb/tsqlquery.html>)
5153
52-This is a descendant of TDataset, and provides the data as a table from the SQL query that you submit. However, it can also be used to execute SQL queries (e.g. stored procedures, INSERT INTO..) that don't return any data. See [[Working With TSQLQuery]] for more details.
54+This is a descendant of TDataset, and provides the data as a table from the SQL query that you submit. However, it can also be used to execute SQL queries (e.g. stored procedures, INSERT INTO..) that don't return any data. See [[Working With TSQLQuery]] for more details.
5355
5456## Using the SQLdb Package
5557
56-To use the SQLdb package, you need a TSQLQuery component, a TSQLTransaction component, and one of the connection components.
58+To use the SQLdb package, you need a TSQLQuery component, a TSQLTransaction component, and one of the connection components.
5759
58-Here is a quick tutorial:
60+Here is a quick tutorial:
5961
60-- Make sure you have the relevant database client/driver installed.
61-- Go to the SQLdb tab in Component Palette.
62-- Add a TXXXConnection component (suitable for the type of database you are using) to a form, and fill in the appropriate properties to connect to your database. These will vary depending on the actual database. Make sure you can set the "connected" property to true.
63-- Add a TSQLTransaction component. Return to the Connection component, and set its Transaction Property to the new transaction. This should also set the transaction's database property. You should be able to set active to true.
64-- Add an SQLQuery component and set its Database property to the connecton component you just added.
65-- Set the SQLQuery "SQL" property. For a first test, just do a "select * from \<tablename\>".
66-- Set active to true. If this works, you have opened your query, and the data is available.
62+ * Make sure you have the relevant database client/driver installed.
63+ * Go to the SQLdb tab in Component Palette.
64+ * Add a TXXXConnection component (suitable for the type of database you are using) to a form, and fill in the appropriate properties to connect to your database. These will vary depending on the actual database. Make sure you can set the "connected" property to true.
65+ * Add a TSQLTransaction component. Return to the Connection component, and set its Transaction Property to the new transaction. This should also set the transaction's database property. You should be able to set active to true.
66+ * Add an SQLQuery component and set its Database property to the connecton component you just added.
67+ * Set the SQLQuery "SQL" property. For a first test, just do a "select * from <tablename>".
68+ * Set active to true. If this works, you have opened your query, and the data is available.
6769
68-From here on, adding controls is the same as for any database, but just to recap:
70+From here on, adding controls is the same as for any database, but just to recap:
6971
70-- Add a TDatasource component (from the Data Access tab) and set its dataset property to the SQLQuery component
71-- Add some controls from the Data Controls tab. For a quick check, add a TDBGrid component, and set its datasource property to the Datasource component you just added. You should see the data from the query you entered.
72+ * Add a TDatasource component (from the Data Access tab) and set its dataset property to the SQLQuery component
73+ * Add some controls from the Data Controls tab. For a quick check, add a TDBGrid component, and set its datasource property to the Datasource component you just added. You should see the data from the query you entered.
7274
73-Of course, this is just the beginning, but getting some data in a grid is usually the first step to ensure the database connection is working. More detailed explanations will be found at [[Working With TSQLQuery]] and [[SQLdb Tutorial1]].
75+Of course, this is just the beginning, but getting some data in a grid is usually the first step to ensure the database connection is working. More detailed explanations will be found at [[Working With TSQLQuery]] and [[SQLdb Tutorial1]].
7476
7577## See also
7678
77-- [[SqlDBHowto]]
78-- [[SQLdb Programming Reference]]
79-- [[Databases]]
80-- [interface view of the classes](http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi?file=index-4&unit=sqldb)
81-- [some additional documentation/notes](http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi?file=fcldbnotes)
79+ * [[SqlDBHowto]]
80+ * [[SQLdb Programming Reference]]
81+ * [[Databases]]
82+ * [interface view of the classes](<http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi?file=index-4&unit=sqldb>)
83+ * [some additional documentation/notes](<http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi?file=fcldbnotes>)
8284
8385---
84-*From the Free Pascal wiki, page "SQLdb Package", as it stood on 2018-06-25 after a change by Af0815, 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).*
86+*From the Free Pascal wiki, page "SQLdb Package", as the Internet Archive kept it on 2026-02-10, last changed on 2024-09-23. 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