RDA同步测试, 已经在本电脑上测试通过

Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe
Imports System.Xml

Public Class Form1
    Dim s_remotestr As String
    Dim s_localstr As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        s_remotestr = "provider=sqloledb;Data Source=172.18.188.19;Initial Catalog=InfoDB;Persist Security Info=True;User ID=sa;Password=sa"
        s_localstr = "Data Source =\now.sdf;Password=sa"
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'pull
        Try
            Dim rda As SqlCeRemoteDataAccess
            rda = New SqlCeRemoteDataAccess()
            rda.LocalConnectionString = s_localstr
            rda.InternetUrl = "http://172.18.188.19/web3/sqlcesa30.dll"
            rda.Pull("t1_temp", "select id,dspname from t1", s_remotestr, RdaTrackOption.TrackingOn, "error")
            MessageBox.Show("success")
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        '修改本地数据
        Try
            '定义连接
            Dim conn As New SqlCeConnection
            conn.ConnectionString = Me.s_localstr
            conn.Open()
            '定义命令
            Dim cmd As New SqlCeCommand
            cmd.Connection = conn
            cmd.CommandText = "update employee set dspname=@a where employeeid=@b"
            '定义参数
            Dim p1 As New SqlCeParameter
            p1.ParameterName = "@a"
            p1.SqlDbType = SqlDbType.NVarChar
            p1.Size = 20
            p1.Value = TextBox2.Text
            Dim p2 As New SqlCeParameter
            p2.ParameterName = "@b"
            p2.SqlDbType = SqlDbType.Int
            p2.Value = TextBox1.Text
            cmd.Parameters.Add(p1)
            cmd.Parameters.Add(p2)
            cmd.ExecuteNonQuery()
            conn.Close()
            MessageBox.Show("成功:修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        'push
        Dim rda As New SqlCeRemoteDataAccess
        Try
            rda.LocalConnectionString = s_localstr
            rda.InternetUrl = "http://172.18.188.19/web3/sqlcesa30.dll"
            rda.Push("employee", s_remotestr)
            MessageBox.Show("success")
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        Finally
            rda.Dispose()
        End Try
    End Sub
End Class

posted @ 2007-06-07 14:56  寒天飞雪  阅读(759)  评论(2编辑  收藏  举报