Condividi tramite


Client/Server Sample Application Database

The database in the Client/Server sample application is small and designed only to show the basics of client/server implementation.

Selecting the Database

You can select the database for the Client/Server sample in Step 1 in the Open Database dialog box. The sample requires Cs.dbc, installed in the same folder that the other files in the Client/Server sample are installed. If your default folder is the Visual FoxPro \Samples\Csapp folder, or if this folder is in your path, the database is automatically selected for you.

The CS database contains the following.

Tables Description
Employee A table with employee ids, names, addresses, and so on.
Emp_init A backup table for employee. After you change the data in the employee table while trying out the options in the sample, you can restore the original data from this table by choosing the Reset Initial Data button in the SampleApp form.
Views Description
Emp_view_local A local view containing all the fields and records from the employee table.
Emp_view_remote A remote view containing all the fields and records from the employee table
Connection Description
Emp_connection A connection to a data source for the emp_view_remote view. You need to establish this connection before you can open emp_view_remote.

Opening the Database

Step 2 in the Open Database dialog box makes it possible for you to open or close the database.

Code associated with the Click event of the Open button opens the database. Before opening the database, the DatabaseIsOpened property of the Engine object is set to True (.T.), assuming that the database will be opened.

OEngine.DatabaseIsOpened = .T.
lcExclusive = IIF(this.parent.chkExclDatabase.value = 1, 'EXCLUSIVE', 'SHARED')
OPEN DATABASE (OEngine.DatabaseFile) &lcExclusive

If the database cannot be opened, the Error event of the Open button is triggered, the DatabaseIsOpened property of the Engine object is set to False (.F.), and an error message is displayed.

Modifying the Remote Connection

Step 3 in the Open Database dialog box makes it possible for you to open the Visual FoxPro Connection Designer to set up a remote connection. You'll need a connection to a back-end database to upsize the table in this sample and access it as a remote view, and you'll need to modify the connection to provide a user ID, password, and connection string.

For information about setting up remote connections, see Creating Views.

Selecting a Data Cursor in the Client/Server Sample Application

The first page on the SampleApp form makes it possible for you to open the table, view, or remote view. The code associated with the Click event of cmdOpen uses the USE command to open the local table, local view, or remote view, based on the Value of the opgCursorType option button group.

The lblStatus label displays status information about the table or view. Code in the GetStatus method of attempts to open the table or view exclusively and updates the label caption. If the table or view could not be opened exclusively, it is opened shared. If it could not be opened shared, the Caption of lblStatus is set to indicate that the table or view is already opened exclusively.

See Also

Solutions Samples | Client/Server Sample | Client/Server Sample Application Classes | Updating Data in the Client/Server Sample Application | Managing Data Conflicts in the Client/Server Sample Application | Implementing Business Rules in the Client/Server Sample Application