19,502
社区成员
发帖
与我相关
我的任务
分享
Private Sub MyPull(ByVal MyTable As String)'ExistTable表中存放PPC本地数据库的所有表格名称,MyTable为要PULL的表格
Dim rdaNW As New SqlCeRemoteDataAccess
Dim dbEngine As New SqlCeEngine
Dim connDB As New SqlCeConnection(strConnLocal)
Dim cmndDB As New SqlCeCommand("SELECT * FROM ExistTable WHERE TableName='" + MyTable + "'", connDB)
Dim drdrDB As SqlCeDataReader
'判断本地数据库是否存在该表
connDB.Open()
drdrDB = cmndDB.ExecuteReader()
If drdrDB.Read = False Then
MsgBox("该表不存在")'表格不存在,则先在MyTable里插入该表名,然后PULL
With cmndDB
.CommandText = "INSERT ExistTable(TableName) VALUES('" + MyTable + "')"
.ExecuteNonQuery()
End With
Else
MsgBox("表格存在!")'表格存在,则先删除本地表,然后PULL
With cmndDB
.CommandText = "DROP TABLE " + MyTable
.ExecuteNonQuery()
End With
End If
connDB.Close()
Try
With rdaNW
.LocalConnectionString = strConnLocal
.InternetUrl = strURL
.InternetLogin = ""
.InternetPassword = ""
.Pull(MyTable, strSQL, strConnRemote, RdaTrackOption.TrackingOn)
End With
MsgBox("Pull OK!")
Catch exSQL As Exception
MsgBox(exSQL.Message)
Finally
rdaNW.Dispose()
End Try
End Sub