The hbasic_dbquery component may be used to display the result of a
database query within a table widget. You have to define the properties
for the database connection with 2 method calls and set the query you want
to execute after that. Start the following steps to display a query result
in a HBasic program:
1) Load the hbasic_dbquery package in the package manager
2) Insert an instance of the hbasic_dbquery component in your project
form.
3) Call the method <compname>.setDbConnect( driver, host, database_name
) to define the database you want to connect to. Driver is the Qt driver
type that depends on that type of your database server. Currently available
Qt database drivers are:
QODBC3 - ODBC (Open Database Connectivity) Driver
QOCI8 - Oracle Call Interface Driver
QPSQL7 - PostgreSQL v6.x and v7.x Driver
QTDS7 - Sybase Adaptive Server and Microsoft SQL Server
Driver
QMYSQL3 - MySQL Driver
4) Call the method <compname>.setDbUser( user, password ) to
define the user who should connect to the database.
5) Call the method <compname>.setQuery( <query_string>
) to define the select statement that should be executed.
If you execute this program you should now see the query result within
the dbquery component.
HBasic program that has been used in the program above:
Sub button1_clicked() queryresult1.setDbConnect( "QMYSQL3", "localhost", "hbasic" ) queryresult1.setDbUser( "db-user", "your-password-for-db-user" ) queryresult1.setQuery( "select * from tab1" ) End Sub
You have to replace db-user and your-password-for-db-user
with a database user created on your database server and it's appropriate
password.