以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  报错事项  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=114985)

--  作者:kaituozhe
--  发布时间:2018/2/27 10:46:00
--  报错事项

一直报错如下,是怎么回事?

NET Framework 版本:2.0.50727.8689
Foxtable 版本:2018.2.28.1
错误所在事件:项目,Client
详细错误信息:
未找到列 [_Identify]。


--  作者:有点甜
--  发布时间:2018/2/27 11:10:00
--  
ReceivedMessage  事件写了什么代码?执行什么操作的时候报错的?
--  作者:kaituozhe
--  发布时间:2018/2/27 11:21:00
--  

以下是客户端代码,shujuyuanmingcheng是数据源名称,用于区别不同的项目

Dim st As Date = Date.Now
Dim msg As String = e.Message
If msg.StartsWith("U#") Then \'表示修改了某行
    Dim pts() As String = msg.Split("#")
    If pts.Length = 4 Then
        If shujuyuanmingcheng = pts(3)  AndAlso DataTables.Contains(pts(1)) = True Then
            msgbox("保存")
            Dim dr As DataRow = DataTables(pts(1)).Find("[_Identify] = " & pts(2))
            If dr IsNot Nothing  Then
                dr.Load() \'重新加载此行
            End If
        End If
    End If
    \'MessageBox.Show("耗时: " & (Date.Now - st).TotalSeconds & "秒")
ElseIf msg.StartsWith("A#") Then \'表示增加了行
    Dim pts() As String = msg.Split("#")
    If pts.Length = 4 Then
        If shujuyuanmingcheng = pts(3) AndAlso DataTables.Contains(pts(1)) = True Then
            msgbox("增加")
            DataTables(pts(1)).AppendLoad("[_Identify] = " &  pts(2)) \'追载新增加的行.
        End If
    End If
ElseIf msg.StartsWith("D#") Then \'表示删除了行
    Dim pts() As String = msg.Split("#")
    If pts.Length = 4 Then
        If shujuyuanmingcheng = pts(3)  AndAlso DataTables.Contains(pts(1)) = True  Then
            msgbox("删除")
            DataTables(pts(1)).RemoveFor("[_Identify] in ("  & pts(2) & ")") \'移除行
        End If
    End If
End If


--  作者:有点甜
--  发布时间:2018/2/27 11:29:00
--  

1、你做什么操作之后报错?

 

2、你删除ReceivedMessage的代码之后,是否还报错?


--  作者:kaituozhe
--  发布时间:2018/2/27 11:34:00
--  

这个软件是在局域网内使用的,如果删除这段代码可能就不会有提示了,但是没有办法同步了


--  作者:kaituozhe
--  发布时间:2018/2/27 11:39:00
--  
保存后就会出错上述情况
--  作者:有点甜
--  发布时间:2018/2/27 11:42:00
--  
以下是引用kaituozhe在2018/2/27 11:34:00的发言:

这个软件是在局域网内使用的,如果删除这段代码可能就不会有提示了,但是没有办法同步了

 

你什么时候触发此段代码?

 

你保存的时候,执行了什么代码?

 

根据错误提示,你某个表没有_Identify列,但是你又用到了此列,自然会报错。


--  作者:kaituozhe
--  发布时间:2018/2/27 15:16:00
--  

这是计划管理中的代码,自动保存。

Dim lst1 As New List(of DataRow)
Dim lst2 As New List(of DataRow)
For Each dt As DataTable In DataTables
    For Each r1 As DataRow In dt.DataRows
        If r1.RowState = DataRowState.Modified Then
            lst1.Add(r1)
        ElseIf r1.RowState = DataRowState.Added Then
            lst2.Add(r1)
        End If
       
    Next
    dt.save
 
    For Each r1 As DataRow In  lst1
        r1.Save()
        Dim p1 As String = "U#"
        \'一定要在保存后合成信息,因为新增行的主键在保存后才生成
        Dim msg1 As String = p1 & dt.name & "#" & r1("_Identify") & "#" & shujuyuanmingcheng
        \'msgbox(msg)
        For Each bd As QQBuddy In QQClient.Buddies
            If bd.Online Then
                QQClient.Send(bd.name, msg1)
            End If
        Next
    Next
    For Each r2 As DataRow In  lst2
        r2.Save()
        Dim p2 As String = "A#"
        \'一定要在保存后合成信息,因为新增行的主键在保存后才生成
        Dim msg2 As String = p2 & dt.name & "#" & r2("_Identify") & "#" & shujuyuanmingcheng
       
        For Each bd As QQBuddy In QQClient.Buddies
            If bd.Online Then
                QQClient.Send(bd.name, msg2)
            End If
        Next
    Next
Next


--  作者:有点甜
--  发布时间:2018/2/27 16:14:00
--  

执行这段代码,看看是否每一个表都有_Identify列

 

For Each dt As DataTable In DataTables
    output.show(dt.name)
    output.show(dt.basetable.columns("_Identify").tostring)
Next