18th Chapter-delphi Client Server application development (d) (1)

Source: Internet
Author: User
Tags interbase join mathematical functions

An overview of 18.3.4.1 adaptation

The so-called adaptation is to convert desktop applications into Client/server applications.

Adaptation is a very complex subject, not described here in detail. This section describes the most important aspects of the applicable Delphi application.

The main aspects of adaptation are:

The adaptation of the database from the desktop platform to the server

Transforming an application into a client/server

The adaptation also needs to realize the transformation from the desktop environment to the CLIENT/SERVER environment.

Desktop and SQL Server databases are different in many ways. For example:

The desktop database is used for single user access at the same time, and the server is used for multiuser access

The desktop database is log-oriented, and the server is a collection-oriented

The desktop database stores each table in a separate file, and the server stores all the tables in the database Client/server application must solve the problem of update, the most complex is join, network and transaction control

18.3.4.2 the database of adaptation

The appropriate database consists of the following steps:

Define metadata on the server based on the structure of the desktop database

Transferring data from the desktop to the server

Address the following issues:

Data type differences

Data Security and integrity

Transaction control

Data access rights

Data legality

Lock

Delphi provides two ways to adapt a database.

Using the Database Desktop tool, select the menu tools/utilities/copy to command to copy the table from the desktop to the SQL format

To build an application that applies the tbatchmove part

Both of these methods can transform the table structure and data from the desktop data source to the server. Depending on these databases, you may need to change the result table. For example, you might want to map different data types.

You can also add the following characteristics to the database:

Integrity constraints

Index

Detection constraint

Stored procedures and triggers

Other Server features

It is more efficient to define metadata with SQL scripts and server data definition tools. The data is then transferred using the two methods described earlier. Because database desktop and tbatchmove parts will only copy data if they are manually defined.

18.3.4.3 Adaptation Application

In theory, Delphi applications designed to access local data can access data on remote servers with little modification. If you define a suitable data source on the server, you can point the application to access it, simply changing the databasename attribute of the ttable or Tquery part in the application.

In fact, there are many important differences between accessing local and process data sources. Client/server applications must address a large number of problems that are not in desktop applications.

Any Delphi application can access data using ttable or tquery parts. Desktop applications usually use the ttable part. Tquery is more effective when applied to a SQL Server, and if the application retrieves a large number of records, the tquery part is slightly.

If your application uses statistics or mathematical functions, it is more efficient to execute these functions through stored procedures on the server. Because stored procedures perform faster, using stored procedures can also reduce network load, especially for a large number of row data functions.

For example, to calculate the standard deviation for a large number of records:

If the function is executed on the client, all values are retrieved from the server and sent to the client, causing network congestion

If the function executes on the server side, then the application only needs answers on the server

18.4 Delphi Client/Server Application Example Analysis

The examples used in this section are examples of Delphi2.0 databases Csdemo. Csdemo is a Delphi client/server Programming sample program that uses a database server that is a local interbase server.

Csdemo a better demonstration of the configuration of the BDE environment, InterBase Server advanced function application, SQL Server join, trigger application, stored procedure programming and transaction control technology, etc., has a high reference value. This section covers the following topics:

Introduction to the database environment

The application of Tdatabase

Switching between tables in different databases

Trigger programming

Stored Procedure Programming

Transaction control applications

Introduction to 18.4.1 Database environment

The database server used in this example is the local interbase server. The local interbase is a single-user version of InterBase Server 32-bit, compatible ANSI SQL. The local interbase supports the development and testing of client/server applications on a stand-alone computer and can be easily adapted to InterBase server. Therefore, it is convenient to develop client/server applications using local InterBase as a prototype development environment.

BDE parameters of 18.4.1.1 iblocal

The SQL database in this example is iblocal. It is made up of the BDE Configuration tool (BDECFG32). EXE) to set the parameter value. Its parameter values are listed in the following table:

Table 18.13 iblocal values of each parameter

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Parameter Name argument value

────────────────────────────────────

TYPE Intrbase

PATH

SERVER NAME C:\INTRBASE\EXAMPLES\EMPLOYEE. Gdb

USER NAME SYSDBA

OPEN MODE Read/write

SCHEMA CACHE SIZE 8

Langdriver

Sqlqrymode

Sqlpassthru MODE SHARED autocommit

SCHEMA Chche TIME-1

MAX ROWS-1

BATCH COUNT 200

ENABLE SCHEMA CACHE FALSE

SCHEMA CACHE DIR

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.