Produkte Shop Support Über Uns |

Einführung in Data Abstract für Delphi (8:41)

Video downloaden | Anschauen auf YouTube

Dies ist ein Video über Data Abstract.
Mehr Data Abstract Videos. Lesen Sie mehr über Data Abstract.

Transcript

Data Abstract is a way to remotely access your data.

More precisely, it is a framework that provides multi-tiered access to a database from multiple platforms. It allows you to create truly database agnostic client apps that efficiently work with data. From desktop to mobile or the web, Data Abstract has you covered.

Let's create our first Data Abstract server and client using Delphi.

In the main menu, choose "File | New | Other". Select the "Data Abstract" folder, pick the "VCL Application" project template, and click "OK".

The Data Abstract wizard offers a few options, For now let's just pick the "Client and New Custom Data Abstract Server" option, which creates both a new server and a client app. We'll explore the other options in another video.

The project wizard allows you to define the set of database connections you commonly use; for this video we will use the "PCTrade sample database that ships with Data Abstract.

Click "Next". The wizard now fetches the database structure. Let's select a few of the tables to make available in our server and click "Next" again. Here, the wizard allows us to fine-tune the server and client projects being created. For now we'll stick with the defaults. Let's pick a location for our project and give it a nicer name.

Click "Finish", and our projects will be created and opened in the Delphi IDE. Let

's look at the server project first. The wizard added a few files to the project.

The DataService module is what exposes our data to the world. You can see it's already populated with a few components that do all the work for us, most interestingly the Schema.

More so than the code, the schema is the heart of a Data Abstract server, and there's a special tool to develop schemas in called the Schema Modeler that is central to working with Data Abstract. Double-click the schema component to open it in Schema Modeler.

Two windows will open in Schema Modeler: one for the schema itself and one for the associated connections file. In the Connection Manager on the right you can manage the live connection to one or more databases. In this case we see the SQLite database we chose before.

The Connection Builder makes it easy to edit or add new ones as needed, but for now what we have is fine.

When we fold open the connection, you can see all the objects in our database are shown. This is a live view of what is in the actual database.

We can easily add more tables to the schema with a simple drag to make them available to client apps.

In the main schema window, we see our objects defined in the schema. Instead of the full database, this is a view of our database as it is exposed to the client applications. We can make changes here: for example, let's remove the notes field so client apps can't access it anymore. We can make further adjustments to customize what the client sees, including renaming whole tables or fields and more.

The statements node of each table has statements that link this table to the underlying database. There could be more than one in a more complex server.

By default, Data Abstract will generate all the SQL for you, but you can also choose to provide a custom SQL statement or even a stored procedure to fetch or update data. If we change the statement type from auto SQL to SQL, we can provide a custom statement which schema modeler pre-fills for us.

As you will see in many places, Data Abstract makes the simple things easy, but also allows you to customize and fine-tune as needed.

Now let's close Schema Modeler and launch our server. Note that we did not actually have to write any custom code or make any other modifications at all for this server. You can if you like, but if not Data Abstract takes care of everything.

Under the hood, Data Abstract uses our remoting SDK framework for the network communication. This is not something you ever have to care about, but it does offer you access to all the flexibility the SDK provides if you need it.

For example, to add custom non database services to the server. By default, our server is now live on port 8099 via HTTPS, serving data via Data Abstract's highly optimized binary data format. Just like on the SDK level, Data Abstract also provides different ways to make your data available in addition to Bin2. For example as REST or OData.

The server exposes a Remoting SDK service called DataService that handles all access to the data when data is accessed. The client calls in to this service internally.

That service consults the schema and the business rules that you defined to determine how the request from the client maps to the actual database. This includes respecting renamed tables and fields, or any other restrictions to ensure the client can only access what it is supposed to.

Back in Delphi, our project group already contains a VCL project that is set up as a client for the server. Keep in mind you can also connect any existing project to the server by adding one of the client module templates available here to your project.

Let's look at the ClientDataModule. This is a regular Delphi data module file and you can see the project wizard has pre-populated it with a set of components that handle the connection to the server. You can also see the data table and data source components you'll be familiar with from any Delphi database for each of the tables we selected before. These are all ready to be hooked up.

Let's switch over to the client form file and add a grid and two buttons. Set the grid's DataSource to the Customers table to hook it up.

Now let's add event handlers for the buttons. We'll add this line to login to the server. By default the Data Abstract server will check for a matching username and password. For a real application you would change the server to check your actual user data.

Simply calling Open on the table will open the connection and populate it.

Sending updated data back to the server is also very easy, as the data table keeps track of all changes performed locally. A simple call to ApplyUpdates takes care of saving them back to the server, and that's it!

Let's launch our app and see it in action. Clicking "Load Data" downloads the customers table from the server.

We can make some changes in the grid – for now these are maintained locally – and finally clicking "Apply Changes" will send those changes back to the server so they can be applied to the database.

Close the app and restart it, and you can see our changes persisted.

And that was a quick introduction to data abstract for Delphi note that the same server can be accessed from client apps written in .NET, Cocoa, Java or even JavaScript. Stay tuned for those videos and more!

Schliessen

Wie können wir Ihnen helfen?

Ihr Name:
Ihre Emailadresse:
 
Ihre Frage:
Schliessen

Vielen Dank!

Ihre Nachricht wurde gesendet und jemand wird sich in Kürze, normalerweise innerhalb eines Werktages, bei Ihnen melden.

Bei technischen Fragen oder Support-Fragen besuchen Sie bitte auch unser RemObjects Talk Support-Forum sowie andere Support-Optionen .