请教老师:我想通过如下代码实现客户端数据表的同步,但执行时没有实现同步,代码如下:
Open客户端的receivedMessage事件中的代码如下:
Dim msg As String = e.Message
If msg.StartsWith("U#") Then '表示修改了某行
Dim pts() As String = msg.Split("#")
If pts.Length = 3 Then
Dim dr As DataRow = DataTables(pts(1)).Find("[_Identify] = " & pts(2))
If dr IsNot Nothing Then
dr.Load() '重新加载此行
End If
End If
ElseIf msg.StartsWith("A#") Then '表示增加了行
Dim pts() As String = msg.Split("#")
If pts.Length = 3 Then
DataTables(pts(1)).AppendLoad("[_Identify] = " & pts(2)) '追载新增加的行.
End If
ElseIf msg.StartsWith("D#") Then '表示删除了行
Dim pts() As String = msg.Split("#")
If pts.Length = 3 Then
DataTables(pts(1)).RemoveFor("[_Identify] = " & pts(2)) '移除行
End If
End If
客户端项目的全局表事件AfterSaveDataRow中写入如下代码:
Dim p, msg As String
If e.StatementType = 0 Then '新增行时
p = "A#"
ElseIf e.StatementType = 1 Then '修改行时
P = "U#"
Else '删除行时
p = "D#"
End If
msg = p & e.DataTable.Name & "#" & e.DataRow("_identify")
For Each bd As qqbuddy In QQClient.Buddies
If bd.OnLine Then
QQClient.Send(bd.Name, msg)
End If
Next
这个表事件不能实现同步吗