以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  合成语句为什么执行不了  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=132816)

--  作者:kaituozhe
--  发布时间:2019/3/30 11:02:00
--  合成语句为什么执行不了

为什么例子中执行黄色部分语句的结果一直接为零,不知道是什么原因,但是用红色部分去试验的时候没有问题,这是什么原因?

Select Case e.DataCol.name
    Case "科目编号"
        Dim biaoshezidrs As List (of DataRow) = DataTables("表设置").Select("表名  = \'科目余额汇总\'and 公司名称 = \'"& e.DataRow("公司名称") & "\' and 列标题 is not null and 列名称 is not null")
        For Each biaoshezidr As DataRow In biaoshezidrs
            If biaoshezidr("列名称").Contains("借方金额") = True Then
                msgbox("公司名称 =  \'"& e.DataRow("公司名称") & "\' and 科目编号 =  \'"& e.DataRow("科目编号") & "\'and  年度 =  \'"& biaoshezidr("列标题").SubString(0,4) & "\'")
                \'msgbox("""" & biaoshezidr("列名称") &"""")
                \'e.DataRow("自定义1_借方金额")  = DataTables("科目余额").Compute("sum(本期发生额_借方金额)","公司名称 =  \'"& e.DataRow("公司名称") & "\' and 科目编号 =  \'"& e.DataRow("科目编号") & "\'and  年度 =  \'"& biaoshezidr("列标题").SubString(1,4) & "\'")
               
                e.DataRow("" & biaoshezidr("列名称") &"")  = DataTables("科目余额").Compute("sum(本期发生额_借方金额)","公司名称 =  \'"& e.DataRow("公司名称") & "\' and 科目编号 =  \'"& e.DataRow("科目编号") & "\'and  年度 =  \'"& biaoshezidr("列标题").SubString(1,4) & "\'")
                msgbox(e.DataRow("" & biaoshezidr("列名称") &""))
                \'msgbox(e.DataRow("自定义1_借方金额"))
            End If
        Next
        e.DataRow("自定义1_借方金额")  = DataTables("科目余额").Compute("sum(本期发生额_借方金额)","公司名称 =  \'"& e.DataRow("公司名称") & "\' and 科目编号 =  \'"& e.DataRow("科目编号") & "\'and  年度 =  \'2009\'")
       
End Select

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目41.foxdb


--  作者:有点蓝
--  发布时间:2019/3/30 11:26:00
--  
e.DataRow(biaoshezidr("列名称"))  = DataTables("科目余额").Compute("sum(本期发生额_借方金额)","公司名称 =  \'" & e.DataRow("公司名称") & "\' and 科目编号 =  \'" & e.DataRow("科目编号") & "\'and  年度 =  \'" & biaoshezidr("列标题").SubString(0,4) & "\'")

数据库sql或者表达式的SubString才是从1开始。

代码里的字符串是从0开始的额