Foxtable(狐表)用户栏目专家坐堂 → 自定义函数问题


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

主题:自定义函数问题

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


加好友 发短信
等级:婴狐 帖子:43 积分:419 威望:0 精华:0 注册:2018/11/1 10:49:00
自定义函数问题  发帖心情 Post By:2019/3/26 15:51:00 [显示全部帖子]

'函数("Add_ID","编号列名","编号字符")

Dim ID_ColName As String = Args(0)
Dim ID_Symbol As String = Args(1)
Dim cmd As New SQLCommand
Dim dt As Date
cmd.C
cmd.CommandText = "Select GetDate()" '从远程数据库获取日期信息
dt = cmd.ExecuteScalar()
CurrentTable.Current("日期") = dt
Dim d As Date = CurrentTable.Current("日期")
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 = ID_Symbol & Format(d,"yyMM") '生成ID_ColName的前6位,2位字符,2位年,2位月.
CurrentTable.Current.Save '***必须在sqlcompute前先保存,才能获得当前行的真实的_identify值***
If CurrentTable.Current(ID_ColName).StartsWith(bh) = False '如果ID_ColName的前6位不符
    Dim max As String
    Dim idx As Integer 
    max = CurrentTable.DataTable.sqlCompute("Max(CurrentTable.Cols(ID_ColName).Name)","[日期] >= '" & fd & "' And [日期] < '" & ld.AddDays(1) & "'And [_Identify] <> " & CurrentTable.Current("_Identify")) '取得该月的最大ID_ColName
    If max > "" Then '如果存在最大ID_ColName
        idx = CInt(max.Substring(6,4)) + 1 '获得最大ID_ColName的后四位顺序号,并加1
    Else
        idx = 1 '否则顺序号等于1
    End If
    CurrentTable.Current(ID_ColName) = bh & Format(idx,"0000")
    CurrentTable.Current.save  
End If

 

 


图片点击可在新窗口打开查看此主题相关图片如下:qq拼音截图未命名.jpg
图片点击可在新窗口打开查看

 

 

建立函数后调用,弹出错误,应该是Max函数的格式问题,但不知道怎么解决


 回到顶部