|
|
|
NOTE: This Design document is subject to change at any time. |
Connection
Syntax: <CONNECTION property-list>
Creates a connection to a database. zApp supports a large variety of different databases natively using the ZeosLib ( www.zeoslib.net ) package, which is based upon JDBC. In addition to the native database support, you can use the Microsoft ADO protocol to access any ODBC or DSN database defined on your system.
Currently, the following native databases are supported:
- ADO (any ODBC, DSN, or OLEDB driver installed on your system)
- MySQL
- MSSQL (Microsoft SQL Server)
- Interbase
- Firebird (open source version of Interbase)
- Oracle
- Sybase
- DB2
- Postgresql
- SQLite
All of these databases are handled in a consistent way and any data-aware component can be connected to one of these databases. You can also freely mix different database connections in a single application.
Some of these databases are powerful client/server systems with complex options and commands. Others are intended for simple, local databases (such as SQLite).
While each database is treated consistently, you are still able to specify database-specific SQL commands as needed. zApp has full transaction support, paging support in the zGrid component, and the ability to handle updates of complex or readonly queries via seperate SQL statements.
To display an interactive dialog allowing the user to select a database at runtime, use the predefined system action "_DBConnect". It allows the user to select from the native protocols and also has a button to bring up the Windows ADO database dialog for connecting to ODBC or DSN databases.
Typically a zConnection object is used to connect to a specific database. Then a zQuery object is tied to the connection to execute a specific query. If you have data-aware controls in the current window, these can be attached to the results of a query via a zDataSource object.
Example:
To connect to a local MS Access database file:
Code: |
<CONNECTION Filename='NORTHWIND.MDB'>
<QUERY Text='SELECT * FROM Customers'>
<DATASOURCE Name='Customers'/>
</QUERY>
</CONNECTION>
<EDIT DataSource='Customers' Field='LastName'/> |
To connect to a remote MySQL database table:
Code: |
<CONNECTION Driver='mysql' Server='www.hostname.com' Database='Northwind' Username='username' Password='password'>
<QUERY Text='SELECT * FROM Customers'>
<DATASOURCE Name='Customers'/>
</QUERY>
</CONNECTION>
<EDIT DataSource='Customers' Field='LastName'/> |
|
|