SQL语句在查询分析器中运行时有结果反馈,但放到VB程序中运行却没有结果,是什么原因? 10
本人有一程序在编写时用到SQL语句,语句放在查询分析器中是可以运行的,有结果,但把语句放到VB程序中后没有结果反馈.语句是有点复杂,有点长,但不知是何原因?SQL1="s...
本人有一程序在编写时用到SQL语句,语句放在查询分析器中是可以运行的,有结果,但把语句放到VB程序中后没有结果反馈.语句是有点复杂,有点长,但不知是何原因?
SQL1 = "select *,IDENTITY(int, 1,1) as 临时 into bb from (Select 类别 , 项目名称 , 数量,单价,金额 From ( " _
& " Select B.隶属类别 类别,B.编号 As 项目编号, B.名称 As 项目名称,B.规格说明,B.计量单位,B.编码,B.医保编码,B.保险类别 As 医保类别, " _
& " B.新农编码 As 农保编码,B.新农分类 As 农保类别,A.单价,sum(A.数量) 数量,sum(A.单价*A.数量) As 金额,A.自付系数B As 自付系数 From " _
& " ALL住院记帐列表 A Inner Join T收费项目 B On A.费用明细=B.编号 And A.住院编号='" & Text1.Text & "' And A.记帐方式<>'处方记帐' And A.作废=0 " _
& " group by B.隶属类别,B.编号, B.名称,B.规格说明,B.计量单位,B.编码,B.医保编码,B.保险类别,B.新农编码,B.新农分类,A.单价,A.自付系数B " _
& " Union All " _
& " Select B.药品类型+'费' 类别,B.编号,B.名称,B.规格,B.药品单位,B.编码,B.医保编码,B.保险类别,B.新农编码,B.新农类别,A.单价,sum(A.数量) " _
& " 数量,sum(A.单项金额) 单项金额,A.自付系数B From ALL住院划价数据 A Inner Join ALL住院划价单 C On A.序号=C.序号 And C.住院编号='" & Text1.Text & "' " _
& " And (C.状态='S' Or C.已被记帐=1) And C.作废=0 Inner Join T药品卫材 B On A.药品编号=B.编号 " _
& " group by B.药品类型,B.编号,B.名称,B.规格,B.药品单位,B.编码,B.医保编码,B.保险类别,B.新农编码,B.新农类别,A.单价,A.自付系数B " _
& " ) VV group by 类别,项目名称 ,单价, 数量,金额) WW select case when 临时 in (select min(临时) " _
& " From bb group by 类别) then 类别 else '' end 列表,项目名称,数量,单价,金额,row_number() over (PARTITIon by 类别 " _
& " order by 项目名称) AS 新临时 From bb order by 类别 drop table bb " 展开
SQL1 = "select *,IDENTITY(int, 1,1) as 临时 into bb from (Select 类别 , 项目名称 , 数量,单价,金额 From ( " _
& " Select B.隶属类别 类别,B.编号 As 项目编号, B.名称 As 项目名称,B.规格说明,B.计量单位,B.编码,B.医保编码,B.保险类别 As 医保类别, " _
& " B.新农编码 As 农保编码,B.新农分类 As 农保类别,A.单价,sum(A.数量) 数量,sum(A.单价*A.数量) As 金额,A.自付系数B As 自付系数 From " _
& " ALL住院记帐列表 A Inner Join T收费项目 B On A.费用明细=B.编号 And A.住院编号='" & Text1.Text & "' And A.记帐方式<>'处方记帐' And A.作废=0 " _
& " group by B.隶属类别,B.编号, B.名称,B.规格说明,B.计量单位,B.编码,B.医保编码,B.保险类别,B.新农编码,B.新农分类,A.单价,A.自付系数B " _
& " Union All " _
& " Select B.药品类型+'费' 类别,B.编号,B.名称,B.规格,B.药品单位,B.编码,B.医保编码,B.保险类别,B.新农编码,B.新农类别,A.单价,sum(A.数量) " _
& " 数量,sum(A.单项金额) 单项金额,A.自付系数B From ALL住院划价数据 A Inner Join ALL住院划价单 C On A.序号=C.序号 And C.住院编号='" & Text1.Text & "' " _
& " And (C.状态='S' Or C.已被记帐=1) And C.作废=0 Inner Join T药品卫材 B On A.药品编号=B.编号 " _
& " group by B.药品类型,B.编号,B.名称,B.规格,B.药品单位,B.编码,B.医保编码,B.保险类别,B.新农编码,B.新农类别,A.单价,A.自付系数B " _
& " ) VV group by 类别,项目名称 ,单价, 数量,金额) WW select case when 临时 in (select min(临时) " _
& " From bb group by 类别) then 类别 else '' end 列表,项目名称,数量,单价,金额,row_number() over (PARTITIon by 类别 " _
& " order by 项目名称) AS 新临时 From bb order by 类别 drop table bb " 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询