以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  怎么把导过来的数据插入到表中?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=64170)

--  作者:lrh9537
--  发布时间:2015/2/6 11:46:00
--  怎么把导过来的数据插入到表中?


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看
怎么把导过来的数据插入到表中?属于哪个单位哪个组的就插入在这个单位组后面?

 

Dim dt1 As DataTable = DataTables("孕检名单")
Dim dt2 As DataTable = DataTables("查询对比")

For Each dr As DataRow In dt2.Select("")
    Dim filter As String = "单位名称 = \'" & dr("单位名称") & "\' and 组名称 = \'" & dr("组名称") & "\' and 女方姓名 = \'" & dr("女方姓名") & "\' and 男方姓名 = \'" & dr("男方姓名") & "\'"
    Dim fdr As DataRow = dt1.Find(filter)
    If fdr Is Nothing Then
        Dim ndr As DataRow = dt1.AddNew
        ndr("女方姓名") = dr("女方姓名")
        ndr("男方姓名") = dr("男方姓名")
ndr("单位名称") = dr("单位名称")
ndr("组名称") = dr("组名称")
ndr("女方姓名") = dr("女方姓名")
ndr("男方姓名") = dr("男方姓名")

    End If
Next


--  作者:Bin
--  发布时间:2015/2/6 12:02:00
--  
什么意思?  参考http://www.foxtable.com/help/topics/2334.htm  利用FInd找到对应的行
--  作者:有点甜
--  发布时间:2015/2/6 12:05:00
--  

 行的次序没有关系的。

 

 导入后,对表格进行一下排序即可。


--  作者:lrh9537
--  发布时间:2015/2/6 13:11:00
--  

我的意思是比如导过来数据,是后河村一组的,就新增一行,插入在后河村一组后面,是二组的就插入在二组的后面。这样不用再排序,数据直接导到该组

 If fdr Is Nothing Then
Dim ndr As DataRow = dt1.AddNew

这个是增加行,需要改成插入行,并且插在单位和组的后面,该怎么改代码?


--  作者:有点甜
--  发布时间:2015/2/6 14:08:00
--  

 不可以,新加入内容后,必须排序。

 

Dim dt1 As DataTable = DataTables("孕检名单")
Dim dt2 As DataTable = DataTables("查询对比")

For Each dr As DataRow In dt2.Select("", "单位名称,组名称")
    Dim filter As String = "单位名称 = \'" & dr("单位名称") & "\' and 组名称 = \'" & dr("组名称") & "\' and 女方姓名 = \'" & dr("女方姓名") & "\' and 男方姓名 = \'" & dr("男方姓名") & "\'"
    Dim fdr As DataRow = dt1.Find(filter)
    If fdr Is Nothing Then
        Dim ndr As DataRow = dt1.AddNew
        ndr("女方姓名") = dr("女方姓名")
        ndr("男方姓名") = dr("男方姓名")
        ndr("单位名称") = dr("单位名称")
        ndr("组名称") = dr("组名称")
        ndr("女方姓名") = dr("女方姓名")
        ndr("男方姓名") = dr("男方姓名")        
    End If
Next