以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]帮看下哪个地方出了问题? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=51964) |
-- 作者:花开的声音 -- 发布时间:2014/6/6 12:59:00 -- [求助]帮看下哪个地方出了问题? 原来ACCESS数据库时运行正常,但转换为SQL数据库后运行出错,如图。 此主题相关图片如下:qq图片20140606125146.jpg 以下代码,看得到显示第1个信息框,看不到第2个信息框就出错误提示了。也就是说在运行dt = cmd.ExecuteReader()这句代码时出错,帮看下哪个地方的问题。 Dim xsxm As WinForm.CheckedComboBox = e.Form.Controls("显示项目") Dim tv As WinForm.TreeView = e.Form.Controls("TreeView1") Dim s As String Dim t As Table Dim filt As String Dim flt As String Dim nlflt As String Dim dr As DataRow Dim dt As DataTable \'Select cxlb.Value \'Case "人员信息" \'Select cxny.Value \' Case "基层法律服务工作者" \' Forms("法律服务人员查询").Open s = e.Form.Controls("显示项目").Text If s = "" OrElse s = "选择显示项目" Then Return End If \'t = Tables("基层法律服务人员信息表") If User.Group = "遵义市司法局" Then filt = "1 = 1" Else filt = "主管司法局 = \'" & User.Group & "\'" End If Dim cmd As New SQLCommand cmd.C cmd.CommandText = "Select [_Identify],身份证号码,主管司法局,法律服务所,性别,姓名,学历学位,学历学位序号,序号,IIF(年龄 < 20 ,\'小于20\',IIF(年龄 Between 20 And 25,\'20-25\',IIF(年龄 Between 26 And 30, \'26-30\',IIF(年龄 Between 31 And 35, \'31-35\'," & _ "IIF(年龄 Between 36 And 40,\'36-40\',IIF(年龄 Between 41 And 45,\'41-45\',IIF(年龄 Between 46 And 50,\'46-50\',IIF(年龄 between 51 And 55,\'51-55\',IIF(年龄 between 56 And 60,\'56-60\',IIF( 年龄 between 61 And 65,\'61-65\',IIF(年龄 between 66 And 70,\'66-70\',\'大于70\'))))))))))) As 年龄" & _ " From {基层法律服务人员信息表} Where " & filt MessageBox.Show("1") dt = cmd.ExecuteReader() MessageBox.Show("2") [此贴子已经被作者于2014-6-6 13:01:47编辑过]
|
-- 作者:有点甜 -- 发布时间:2014/6/6 14:10:00 -- sqlserver 没有 iif 函数,要用 case when 替换
http://blog.sina.com.cn/s/blog_61fbf8d10100lian.html
|
-- 作者:花开的声音 -- 发布时间:2014/6/6 17:26:00 -- 有点甜老师,按链接学习了下,还是不太会替换呢。你帮我改造下 |
-- 作者:有点甜 -- 发布时间:2014/6/6 17:32:00 -- 做两个,剩下自己做
cmd.CommandText = "Select [_Identify],身份证号码,主管司法局,法律服务所,性别,姓名,学历学位,学历学位序号,序号, (case when 年龄 < 20 then \'小于20\' when 年龄 <= 30 then \'20-30\' else \'大于 30\' end) As 年龄" & _ [此贴子已经被作者于2014-6-6 17:32:02编辑过]
|