Server Database Connections

From HTML5 Builder
Jump to: navigation, search

HTML5 Builder server-side applications, both web and mobile, can interact with database servers to retrieve, modify, add and remove data.

There are several approaches you can follow:

Components

You can combine data-access components and data controls to develop web applications that read or write on databases, and can perform advanced operations with them. Follow the steps below to configure a connection:

Note: You can use the Data Explorer instead to speed up the whole process.

Connect to a Database

To work with a database, you first need to get a working connection to one. In HTML5 Builder, the component that takes care of that connection is Database. You can either add a Database component to your application from the Tool Palette and then configure it, or you can drop a database onto the Designer directly from the Data Explorer, which will generate a Database component already configured.

Configure a DataSet

Once the connection is ready, you need to retrieve some data from it. There are several components you can use to retrieve data from a Database, those called DataSet components, components that extend the DataSet class.

DataSet components perform a query on the Database component and store the resulting data.

Associate a Component to the DataSet

There are some components that can be associated with a DataSet component so the former renders the data in the second. Those components are called data-aware components. But in order to make that association, you need a connector, a bridge between the DataSet component and the data-aware component: a Datasource component. That is why all data-aware components have a DataSource property you have to point to that DataSource component.

So once you have a working DataSet component, you need to:

That is it. Your component will now work with the data from the database.

Using a Data Module

You can place any Database, DataSet and Datasource components in a server data module. That way, you can later include that module from any other page, avoiding duplicated work by reusing the same components.

Components and Code

After you follow the component-based approach to configure a Database component and link one or more DataSet components to it, you can directly access the data from the latter using code.

For information on how to interact with these components from code, see DataSet Components.

Tools

The following tools will help you work with databases:

Data Explorer
It lets you browse your databases, generate components already set up to work with them, and more.
Query Designer
Design queries to be executed against your databases in a visual way.
Data Viewer
Read, edit and create data from your databases.

Help Resources

Tutorials

Video Tutorials

See Also