Foxtable(狐表)用户栏目专家坐堂 → 关于合并数据与DataColChanged事件的使用问题


  共有1818人关注过本帖树形打印复制链接

主题:关于合并数据与DataColChanged事件的使用问题

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/8/24 20:59:00 [显示全部帖子]

以下是引用zhimin在2017/8/24 20:45:00的发言:
谢谢,搞定了!
还有一个问题,用代码实现合并数据时如何进行主键比较,剔除重复行?

 

要用代码处理,比如

 

http://www.foxtable.com/webhelp/scr/2334.htm

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=101056&replyID=694684&skin=1

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=102938&skin=0

 

http://www.foxtable.com/webhelp/scr/2137.htm

 

[此贴子已经被作者于2017/8/24 20:59:57编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/8/24 23:23:00 [显示全部帖子]

SystemReady = False
Try
    Dim dlg As  new OpenFileDialog
    If dlg.ShowDialog = DialogResult.OK Then
        If Connections.Contains("test") Then Connections.Delete("test")
        Connections.Add("test","Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dlg.FileName & ";Persist Security Info=False")
        For Each tn As String In Connections("test").GetTableNames
            Dim cmd As New SQLCommand
            Dim dt As DataTable
            cmd.ConnectionName = "test"
            cmd.CommandText = "SELECT * From {" & tn & "}"
            dt = cmd.ExecuteReader()
            For Each dr As DataRow In dt.DataRows
                Dim fdr As DataRow = DataTables(tn).Find("主键列名 = '" & dr("主键列名") & "'")
                If fdr Is Nothing Then fdr = DataTables("员工").AddNew()
                For Each dc As DataCol In dt.DataCols
                    fdr(dc.name) = dr(dc.name)
                Next
            Next
        Next
    End If
[此贴子已经被作者于2017/8/24 23:37:18编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/8/24 23:37:00 [显示全部帖子]

SystemReady = False
Try
    Dim dlg As  new OpenFileDialog
    If dlg.ShowDialog = DialogResult.OK Then
        If Connections.Contains("test") Then Connections.Delete("test")
        Connections.Add("test","Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dlg.FileName & ";Persist Security Info=False")
        For Each tn As String In Connections("test").GetTableNames
            Dim cmd As New SQLCommand
            Dim dt As DataTable
            cmd.ConnectionName = "test"
            cmd.CommandText = "SELECT * From {" & tn & "}"
            dt = cmd.ExecuteReader()
            For Each dr As DataRow In dt.DataRows
                Dim fdr As DataRow = DataTables(tn).Find("主键列名 = '" & dr("主键列名") & "'")
                If fdr Is Nothing Then fdr = DataTables("员工").AddNew()
                For Each dc As DataCol In dt.DataCols
                    fdr(dc.name) = dr(dc.name)
                Next
            Next
        Next
    End If
   
   
Catch ex As Exception
    MessageBox.Show("追加数据失败")
End Try
SystemReady = True

 回到顶部