4
0
2024-05-08 11:33:28
Sub OnLButtonDown(ByVal Item, ByVal Flags, ByVal x, ByVal y)
Dim kj1,kj2,kj3,kj4kj5,kj6
Dim QR
Dim MSFlexGrid1
Dim LocalBeginTime,LocalEndTime,riqi
Dim oRs,oRs1,n,n1,i,z,s1,s11,oCom,oCom1,strcn,conn,pj
Dim zxy1
Dim Date1,Date2,BY,Bm,Bd,Ey,Em,Ed,BeginDate,EndDate
Set MSFlexGrid1=ScreenItems("zz")
'riqi = Now
Set Date1 = ScreenItems("s1")
Set Date2 = ScreenItems("s2")
By = Year(Date1.Value)
Bm = Month(Date1.Value)
Bd = Day(Date1.Value)
Ey = Year(Date2.Value)
Em = Month(Date2.Value)
Ed = Day(Date2.Value)
BeginDate = By & "-" & Bm & "-" & Bd & " " & "00:00:00"
EndDate = Ey & "-" & Em & "-" & Ed & " " & "23:59:59"
'日期比较
If ( By > Ey ) Or ( By = Ey And Bm > Em ) Or ( By = Ey And Bm = Em And Bd > Ed ) Then
MsgBox "输入的时间不正确!", vbOK, "错误的起始时间"
End If
'LocalBeginTime = Year(riqi) & "-" & Month(riqi) & "-" & Day(riqi) & " " & "00:00:00"
'LocalEndTime = Year(riqi) & "-" & Month(riqi) & "-" & Day(riqi) & " " & "23:59:59"
s1 = "SELECT DT,B1,B2,B3,B4,B5,B6,B7,B8,B9 FROM BIAO WHERE DT BETWEEN '" & BeginDate & "' and'" & EndDate & "'ORDER BY DT"
s11="SELECT DT,SUM(B1)AS B1,SUM(B2)AS B2,SUM(B3)AS B3,SUM(B4)AS B4,SUM(B5)AS B5,SUM(B6)AS B6,SUM(B7)AS B7,SUM(B8)AS B8,SUM(B9)AS B9 FROM BIAO WHERE DT BETWEEN '" & BeginDate & "' and'" & EndDate & "'ORDER BY DT"
strcn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist SecurityInfo=False;Initial Catalog=cbc;Data Source=CZBC0423\WINCC"
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = strcn
conn.CursorLocation = 3
conn.Open
'使用命令文本查询
Set oRs = CreateObject("ADODB.Recordset")
Set oCom = CreateObject("ADODB.Command")
oCom.CommandType = 1
Set oCom.ActiveConnection = conn
oCom.CommandText = s1
Set oRs = oCom.Execute
n = oRs.RecordCount'查询到的记录数目
' Set oRs1 = CreateObject("ADODB.Recordset")
Set oCom1 = CreateObject("ADODB.Command")
oCom1.CommandType = 1
Set oCom1.ActiveConnection = conn
oCom1.CommandText = s11
Set oRs1
这个是vbs按钮查询,为什么不求和呢,
楼主最近还看过