本节介绍在 DbmlsyncClient 类的 C++ 实现中的方法。
以下示例显示了一个使用 C++ 版本的 Dbmlsync API 执行同步以接收输出事件的典型应用程序。为清晰起见,示例省略了错误处理。检查每个 API 调用的返回值始终是良好的习惯。
#include <stdio.h> #include "dbmlsynccli.h" int main( void ) { DbmlsyncClient *client; DBSC_SyncHdl syncHdl; DBSC_Event *ev1; client = DbmlsyncClient::InstantiateClient(); if( client == NULL ) return( 1 ); client->Init(); // Setting the "server path" is usually required on Windows Mobile/CE. // In other environments the server path is usually not required unless // you SA install is not in your path or you have multiple versions of the // product installed client->SetProperty( "server path", "C:\\SQLAnywhere\\bin32" ); client->StartServer( 3426, "-c eng=remote;dbn=rem1;uid=dba;pwd=sql -v+ -ot c:\\dbsync1.txt", 5000, NULL ); client->Connect( NULL, 3426, "dba", "sql"); syncHdl = client->Sync( "my_sync_profile", "" ); while( client->GetEvent( &ev1, 5000) == DBSC_GETEVENT_OK ) { if( ev1->hdl == syncHdl ) { // // Process events that interest you here // if( ev1->type == DBSC_EVENTTYPE_SYNC_DONE ) { client->FreeEventInfo( ev1 ); break; } client->FreeEventInfo( ev1 ); } } client->ShutdownServer( DBSC_SHUTDOWN_ON_EMPTY_QUEUE ); client->WaitForServerShutdown( 10000 ); client->Disconnect(); client->Fini(); delete client; return( 0 ); } |
下面介绍了在 API 的 C++ 版本中的 DbmlsyncClient 类公共方法。
InstantiateClient 方法
Init 方法
Fini 方法
StartServer 方法
Connect 方法
Disconnect 方法
Ping 方法
Sync 方法
ShutdownServer 方法
WaitForServerShutdown 方法
CancelSync 方法
GetEvent 方法
FreeEventInfo 方法
GetErrorInfo 方法
SetProperty 方法
GetProperty 方法
DBSC_Event 结构
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |