有关 CustDB 示例数据库的详细信息,请参见建立 CustDB 统一数据库。
上一课中创建的 CustdbScripts.dll 封装了 UploadInsert() 和 DownloadCursor() 方法。这些方法分别包含 ULCustomer upload_insert 和 download_cursor 事件的实现。
在本节中,可以用两种方法为表级事件指定类方法:
使用 MobiLink 同步插件。
使用 Sybase Central 连接到 CustDB 数据库,将 upload_insert 脚本的语言更改为 .NET,然后指定 MLExample.CustdbScripts.UploadInsert 来处理事件。
使用 ml_add_dnet_table_script 存储过程。
通过 Interactive SQL 连接到 CustDB 数据库并执行 ml_add_dnet_table_script,从而指定 MLExample.CustdbScripts.DownloadCursor 来处理 download_cursor 事件。
使用 MobiLink 同步插件连接到示例数据库:
启动 Sybase Central。
在 [视图] 菜单中,确保已选择 [文件夹]。
在 [连接] 菜单中,选择 [使用 MobiLink 11 连接]。
在 [标识] 选项卡上,选择 [ODBC 数据源名称] SQL Anywhere 11 CustDB。
单击 [确定] 进行连接。
现在,Sybase Central 应在 MobiLink 11 插件下显示 CustDB 数据源。
将 ULCustomer 表 upload_insert 事件的语言更改为 .NET:
在左窗格中,打开 [同步表] 文件夹,然后选择 ULCustomer 表。在右窗格中,出现一个表级别脚本列表。
在右窗格中,打开 custdb 11.0 upload_insert 表脚本。在 [文件] 菜单中,选择 [语言],并将语言更改为 .NET。
输入用于 custdb 11.0 upload_insert 表脚本的 .NET 方法名称。
删除 upload_insert 表脚本的内容,以确保右窗格显示为空白。
在右窗格中键入以下内容:
MLExample.CustdbScripts.UploadInsert |
从 [文件] 菜单中选择 [保存] 以保存脚本。
退出 Sybase Central。
此步骤使用 Sybase Central 将 .NET 方法指定为 ULCustomer upload_insert 事件的脚本。
也可以使用 ml_add_dnet_connection_script 和 ml_add_dnet_table_script 存储过程。使用这些存储过程效率更高,特别是在使用大量 .NET 方法处理同步事件时。
请参见ml_add_dnet_connection_script 系统过程和ml_add_dnet_table_script 系统过程。
在下一节中,您将通过 Interactive SQL 连接到 CustDB 并执行 ml_add_dnet_table_script,从而将 MLExample.CustdbScripts.DownloadCursor 指派给 download_cursor 事件。
使用 Interactive SQL 连接到示例数据库。
选择 [开始] » [程序] » [SQL Anywhere 11] » [Interactive SQL],或运行以下命令:
dbisql |
单击 [标识] 选项卡。
单击 [ODBC 数据源名称],然后键入 SQL Anywhere 11 CustDB。
单击 [确定] 进行连接。
在 Interactive SQL 中执行以下命令:
CALL ml_add_dnet_table_script( 'custdb 11.0', 'ULCustomer', 'download_cursor', 'MLExample.CustdbScripts.DownloadCursor'); COMMIT; |
以下是对每个参数的说明:
参数 | 说明 |
---|---|
custdb 11.0 | 脚本版本。 |
ULCustomer | 同步表。 |
download_cursor | 事件名。 |
MLExample.CustdbScripts.DownloadCursor | 完全限定 .NET 方法。 |
退出 Interactive SQL。
在本课中,您指定了 .NET 方法来处理 ULCustomer 表级别事件。下一课将确保 MobiLink 服务器装载正确的类文件和 MobiLink 服务器 API。
有关添加和删除同步脚本的详细信息,请参见添加和删除脚本。
有关本课所用脚本的详细信息,请参见ml_add_dnet_connection_script 系统过程和ml_add_dnet_table_script 系统过程。
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |