以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  字符串 ' And [_Identify] <> 32' 后的引号不完整。  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=110671)

--  作者:yifan3429
--  发布时间:2017/12/7 11:21:00
--  字符串 ' And [_Identify] <> 32' 后的引号不完整。
字符串 \' And [_Identify] <> 32\' 后的引号不完整。
--  作者:有点甜
--  发布时间:2017/12/7 11:39:00
--  

贴出完整代码,你合成的字符串的代码要这样写

 

Dim str As String = 32

Dim filter As String = " And _Identify <> " & str


--  作者:yifan3429
--  发布时间:2017/12/7 16:39:00
--  
新增行时出现的错误
--  作者:有点甜
--  发布时间:2017/12/7 16:57:00
--  
出错提示贴出来,贴出对应的代码。
--  作者:yifan3429
--  发布时间:2017/12/7 16:58:00
--  
.NET Framework 版本:2.0.50727.5485
Foxtable 版本:2017.10.26.1
错误所在事件:
详细错误信息:
字符串 \' And [_Identify] <> 37\' 后的引号不完整。


If e.DataCol.Name = "日期" Then
    If e.DataRow.IsNull("日期") Then
        e.DataRow("产品号") = Nothing
    Else
        Dim d As Date = e.DataRow("日期")
        Dim lb As String = "CP"
        Dim y As Integer = d.Year
        Dim m As Integer = d.Month
        Dim Days As Integer = Date.DaysInMonth(y,m)
        Dim fd As Date = New Date(y,m,1) \'获得该月的第一天
        Dim ld As Date = New Date(y,m,Days) \'获得该月的最后一天
        Dim bh As String = Format(d,"yyyyMM") \'生成产品号的前6位,4位年,2位月.
        If e.DataRow("产品号").StartsWith(bh) = False \'如果产品号的前6位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.sqlCompute("Max(产品号)","日期 >= \'" & fd & "\' And 日期 <= #" & ld & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该月的最大产品号
            If max > "" Then \'如果存在最大产品号
                idx = CInt(max.Substring(10,5)) + 1 \'获得最大产品号的后三位顺序号,并加1
            Else
                idx = 1 \'否则顺序号等于1
            End If
            e.DataRow("产品号") = lb &"-" & bh & "-" & Format(idx,"00000")
        End If
    End If
End If

\'If e.DataCol.Name = "状态" Then \'如果是已结帐列的内容变动
    \'If e.NewValue <> "新单" Then \'而且变动后的值是True(已勾选)
        \'e.DataRow.Locked = True \'那么锁定此行
    \'End If
\'End If
[此贴子已经被作者于2017/12/7 17:01:27编辑过]

--  作者:有点甜
--  发布时间:2017/12/7 17:14:00
--  

如果是sqlserver数据库

 

max = e.DataTable.sqlCompute("Max(产品号)","日期 >= \'" & fd & "\' And 日期 <= \'" & ld & "\' And [_Identify] <> " & e.DataRow("_Identify")) \'取得该月的最大产品号

 

如果是access数据库

 

max = e.DataTable.sqlCompute("Max(产品号)","日期 >= #" & fd & "# And 日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该月的最大产品号