有一个wicc项目一直运行在w7系统的wicc7.2版本,因为电脑老化换了台新电脑,W10的系统安装了wicc7.5现在wicc功能都正常就是报表无法查询,点了查询按钮无反应,帮我看看怎么回事,下边是查询按钮的VB脚本,还有部分代码字数限制未显示。
Sub OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)
Dim conn '定义类对象
Dim SCon '定义数据库连接字符串
Dim oRs1,oRs2,oRs3,oRs4 '定义获取到的数据集
Dim oCom
Dim m
Dim strSQL1,strSQL2,strSQL3,strSQL4
'定义日报筛选条件,即年月日的获取
Dim My_Month,My_Year,My_Day
My_Year =HMIRuntime.Tags("My_Year").Read
My_Month=HMIRuntime.Tags("My_Month").Read
My_Day=HMIRuntime.Tags("My_Day").Read
'数据库连接字符串
sCon= "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=baobiao1;Data Source=.\WINCC"
strSQL1= "SELECT convert(char(13),riqi,21),VD2000,VD2004,VD2008,VD2012,VD2016,VD2020,VD2024,VD2028,VD2032,VD2036,VD2040 FROM ribao2 where month(riqi) = '"&My_Month&"' and Day(riqi) ='"&My_Day&"' And Year(riqi) = '"&My_Year&"' Order By riqi Asc;"
strSQL2= "SELECT min(VD2000),min(VD2004),min(VD2008),min(VD2012),min(VD2016),min(VD2020),min(VD2024),min(VD2028),min(VD2032),min(VD2036),min(VD2040) FROM ribao2 where month(riqi) = '"&My_Month&"' and Day(riqi) ='"&My_Day&"' And Year(riqi) = '"&My_Year&"' ;"
strSQL3= "SELECT AVG(VD2000),AVG(VD2004),AVG(VD2008),AVG(VD2012),AVG(VD2016),AVG(VD2020),AVG(VD2024),AVG(VD2028),AVG(VD2032),AVG(VD2036),AVG(VD2040) FROM ribao2 where month(riqi) = '"&My_Month&"' And Day(riqi) ='"&My_Day&"' And Year(riqi)= '"&My_Year&"' ;"
strSQL4= "SELECT max(VD2000),max(VD2004),max(VD2008),max(VD2012),max(VD2016),max(VD2020),max(VD2024),max(VD2028),max(VD2032),max(VD2036),max(VD2040) FROM ribao2 where month(riqi) = '"&My_Month&"' And Day(riqi) ='"&My_Day&"' and Year(riqi) ='"&My_Year&"' ;"
Set conn=CreateObject("ADODB.Connection")
conn.ConnectionString = sCon
conn.CursorLocation = 3
conn.Open
Set oRs1 = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1
Set oCom.ActiveConnection = conn
oCom.CommandText = strSQL1
Set oRs1 = oCom.Execute '获取查询的历史数据集,是虚拟的数据结果表
m = oRs1.RecordCount
oCom.CommandText = strSQL2
Set oRs2 = oCom.Execute '获取查询的最小数据集,是虚拟的数据结果表
oCom.CommandText = strSQL3
Set oRs3 = oCom.Execute '获取查询的平均数据集,是虚拟的数据结果表
oCom.CommandText = strSQL4
Set oRs4 = oCom.Execute '获取查询的最大数据集,是虚拟的数据结果表
'表格初始化,获取窗体上的报表控件名称,如果是自己添加一定要对应名称
Dim olist
Set olist = ScreenItems("日报表1")
olist.clear
olist.Cols=16
olist.Rows =m+4
'列内容居中显示
olist.ColAlignment(0)=3
olist.ColAlignment(1)=3
olist.ColAlignment(2)=3
olist.ColAlignment(3)=3
olist.ColAlignment(4)=3
olist.ColAlignment(5)=3
olist.ColAlignment(6)=3
olist.ColAlignment(7)=3
olist.ColAlignment(8)=3
olist.ColAlignment(9)=3
olist.ColAlignment(10)=3
olist.ColAlignment(11)=3
olist.ColAlignment(12)=3
olist.ColAlignment(13)=3
'设置列宽
olist.ColWidth(0) = 800
olist.ColWidth(1) = 1800
olist.ColWidth(2) = 1200
olist.ColWidth(3) = 1200
olist.ColWidth(4) = 1200
olist.ColWidth(5) = 1200
olist.ColWidth(6) = 1200
olist.ColWidth(7) = 1200
olist.ColWidth(8) = 1200
' '设置标头
' oList.TextMatrix(0, 0) = "编号"
' oList.TextMatrix(0, 1) = "日期"
' oList.TextMatrix(0, 2) = "VD1000"
' oList.TextMatrix(0, 3) = "VD1004"
' oList.TextMatrix(0, 4) = "VD1008"
' oList.TextMatrix(0, 5) = "VD1012"
' oList.TextMatrix(0, 6) = "VD1016"
' oList.TextMatrix(0, 7) = "VD1020"
' oList.TextMatrix(0, 8) = "VD1024"
' oList.TextMatrix(0, 9) = "VD1028"
' oList.TextMatrix(0, 10) ="VD1032"
'设置标头
oList.TextMatrix(0, 0) = "编号"
oList.TextMatrix(0, 1) = "日期"
oList.TextMatrix(0, 2) = "DO_501"
oList.TextMatrix(0, 3) = "DO_502"
oList.TextMatrix(0, 4) = "DO_503"
oList.TextMatrix(0, 5) = "DO_504"
oList.TextMatrix(0, 6) = "ORP_501"
oList.TextMatrix(0, 7) = "ORP_502"
oList.TextMatrix(0, 8) = "SS_501"
oList.TextMatrix(0, 9) = "SS_502"
oList.TextMatrix(0, 10) = "PH_501"
oList.TextMatrix(0, 11) = "PH_502"
oList.TextMatrix(0, 12) = "SS_701"
Dim i
i=0
'如果查询不到数据,提示没有符合条件的记录,如果有数据,把数据写入报表控件
If (oRs1.EOF) Then
MsgBox("没有符合条件的记录")
Else
'循环把查询数据到的数据,一行一行写入报表控件
While i<(m)
i=i+1
oList.TextMatrix(i, 0) = CStr(i)
oList.TextMatrix(i, 1) = CStr(oRs1.Fields(0).Value)
oList.TextMatrix(i, 2) = FormatNumber(oRs1.Fields(1).Value,2) '保留两位小数
oList.TextMatrix(i, 3) = FormatNumber(oRs1.Fields(2).Value,2) '保留两位小数
oList.TextMatrix(i, 4) = FormatNumber(oRs1.Fields(3).Value,2) '保留两位小数
oList.TextMatrix(i, 5) = FormatNumber(oRs1.Fields(4).Value,2) '保留两位小数
oList.TextMatrix(i, 6) = FormatNumber(oRs1.Fields(5).Value,2) '保留两位小数
oList.TextMatrix(i, 7) = FormatNumber(oRs1.Fields(6).Value,2) '保留两位小数
oList.TextMatrix(i, 8) = FormatNumber(oRs1.Fields(7).Value,2) '保留两位小数
oList.TextMatrix(i, 9) = FormatNumber(oRs1.Fields(8).Value,2) '保留两位小数
oList.TextMatrix(i, 10) = FormatNumber(oRs1.Fields(9).Value,2) '保留两位小数
oList.TextMatrix(i, 11) = FormatNumber(oRs1.Fields(10).Value,2) '保留两位小数
oList.TextMatrix(i, 12) = FormatNumber(oRs1.Fields(11).Value,2) '保留两位小数
oRs1.MoveNext '移到下一行
Wend
MsgBox "查询到+'"&M&"'+条数据, 提示!",0,"温馨提示:"
'合计内容,显示到最后一行
oList.TextMatrix(m+1, 0) = "最大值"
oList.TextMatrix(m+1, 1) = " "
oList.TextMatrix(m+1, 2) = FormatNumber(oRs4.Fields(0).Value,2) '保留两位小数
oList.TextMatrix(m+1, 3) = FormatNumber(oRs4.Fields(1).Value,2) '保留两位小数
oList.TextMatrix(m+1, 4) = FormatNumber(oRs4.Fields(2).Value,2) '保留两位小数
oList.TextMatrix(m+1, 5) = FormatNumber(oRs4.Fields(3).Value,2) '保留两位小数
oList.TextMatrix(m+1, 6) = FormatNumber(oRs4.Fields(4).Value,2) '保留两位小数
oList.TextMatrix(m+1, 7) = FormatNumber(oRs4.Fields(5).Value,2) '保留两位小数
oList.TextMatrix(m+1, 8) = FormatNumber(oRs4.Fields(6).Value,2) '保留两位小数
oList.TextMatrix(m+1, 9) = FormatNumber(oRs4.Fields(7).Value,2) '保留两位小数
oList.TextMatrix(m+1, 10) = FormatNumber(oRs4.Fields(8).Value,2) '保留两位小数
oList.TextMatrix(m+1, 11) = FormatNumber(oRs4.Fields(9).Value,2) '保留两位小数
oList.TextMatrix(m+1, 12) = FormatNumber(oRs4.Fields(10).Value,2) '保留两位小数
'平均内容,显示到最后一行
MsgBox "查询到+'"&M&&q