Set up workstation and server clock synchronization in C/S system

Source: Internet
Author: User
Tags integer local time microsoft sql server odbc connection sybase sybase database win32

Absrtact: In practical application, the clock of each workstation in client/server architecture is often required to keep synchronized with the server clock; This paper illustrates a solution based on Sybase database and PowerBuilder development tool.

First, the preface

PowerBuilder through the Data window object, the database can be operated conveniently and directly, so it has become the first Choice development tool for developing Client/server mode application. In the development of hospital information Management system, we used PowerBuilder as the foreground development tool, Sybase as the background database.

In hospital information management system, there are many modules require workstation time and server to keep in sync, such as: outpatient fee system requires to be able to evenly to the Siyao window distribution prescriptions, hospital pharmacies to be placed according to the ward to send orders in time order. To solve this problem, we have written a corresponding program, the main idea is: the use of dynamic cursors to obtain server time, WIN32 API functions to set the local time, the specific implementation of the following methods:

Second, the realization method:

1, connect the database

PowerBuilder supports a variety of database management systems (DBMS), such as Sybase, Oracle, Informix, Microsoft SQL Server, and so on, depending on the type of database, using a private interface or ODBC connection database. Establish the interface configuration file (DB profile).

2. Create Application object, write script in Application object event

The script for the 1>, Application object Open event is as follows:

startupfile = "settime.ini"
sqlca.DBMS= ProfileString (startupfile, "database", "dbms", "")
sqlca.database=ProfileString(startupfile,"database","database","")
sqlca.userid=ProfileString(startupfile,"database","userid","")
sqlca.dbpass=ProfileString(startupfile,"database","dbpass", "")
sqlca.logid=ProfileString(startupfile, "database", "logid","")
sqlca.logpass=ProfileString (startupfile, "database","LogPassWord", "")
sqlca.servername=ProfileString(startupfile,"database",ervername","")
sqlca.dbparm= ProfileString (startupfile, "database", "dbparm", "")
connect;
f_setlocaltime() //调用自定义函数完成设置本地工作站时间

The script in the 2>, Application object Close event is as follows:

DISCONNECT Using SQLCA;

3, the definition of WIN32 API functions for external functions

In the Script Brush workspace, select Declare > Global External functions ..., which defines the WIN32 API function as an external function, defined as follows:

FUNCTION LONG SetLocalTime (ref systemtime systimeptr) LIBRARY "Kernel32.dll"

4. Define the structure of access time parameters

Click the Structure Painter button in Painterbar or Powerpanel to define a structure named: SYSTEMTIME, the variables that compose the structure and the corresponding data types are as follows:

integer wyear
integer wmonth
integer wdayofweek
integer wday
integer whour
integer wminute
integer wsecond
integer wmillisecond

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.