Home > Software engineering >  PC using SQL data read Listview control problems
PC using SQL data read Listview control problems

Time:09-30

VB program is as follows:
 Sub OnLButtonDown (ByVal Item, ByVal Flags, ByVal x, ByVal y) 

'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Dim con
Dim kongjian1
The Set kongjian1=ScreenItems (" four control ")
Kongjian1. Visible=1
Dim STR
'Dim blnOK
Dim SQL
Dim it
Dim I
Dim RST
Dim CMD
Dim obj
Dim ok

Dim qyear
Dim qmonth
Dim qday
Dim qhour
Dim qendyear
Dim qendmonth
Dim qendday
Dim qendhour



Dim t1, t2

On the Error Resume Next
The Set obj=ScreenItems (" four control ")


Obj. Listitems. Clear

The Set of con=CreateObject (" ADODB. Connection ")

STR="Provider=MSDASQL; DSN=yx; Uid=sa; The Pwd=;"
Con. The ConnectionString=STR
Con. Open

If con. State=1 Then
Dim rili
The Set rili=ScreenItems (rq1)
During qyear=rili.
Qmonth=rili. The month
Qday=rili. Day
Qhour=rili. Hour





If qmonth<10 then
If qday<10 then
T1=qyear & amp; "0" & amp; Qmonth & amp; "0" & amp; Qday
The Else
T1=qyear & amp; "0" & amp; Qmonth & amp; "-" & amp; Qday
End the If
End the If
If qmonth> 10 Then=
If qday<10 Then
T1=qyear & amp; "-" & amp; Qmonth & amp; "0" & amp; Qday

The else
T1=qyear & amp; "-" & amp; Qmonth & amp; "-" & amp; Qday

End the If
End the If
Dim d1
Dim d2
D1=t1 & amp; "00" & amp; ": 00" & amp; ": 00
"D2=t1 & amp; "23" & amp; ":" 59 & amp; ": 00
"SQL="select * from dbo. Daily report where time & gt;='" & amp; D1 & amp;" 'and the time & lt;='" & amp; D2 & amp;" 'the order by the time the ASC "
Mand Set CMD=CreateObject (" ADODB.Com ")
CMD. The ActiveConnection=con
Cmd.Com mandText=SQL
The Set RST=CreateObject (" ADODB. You ")
The Set RST=CMD. The Execute

I=1
EOF
Do Until RST.The Set of it=obj. ListItems. Add
It. The Text=I
It. Subitems (1)=RST. Fields (" time "). The value
It. Subitems (2)=RST. Fields (" water level "). The value
It. Subitems (3)=RST. Fields (" 1 _ the water level difference "). The value
It. Subitems (4)=RST. Fields (" 2 _ the water level difference "). The value
It. Subitems (5)=RST. Fields (" water temperature "). The value
It. Subitems (6)=RST. Fields (" water ammonia nitrogen "). The value
It. Subitems (7)=RST. Fields (" water COD "). The value
It. Subitems (8)=RST. Fields (" water PH "). The value
It. Subitems (9)=RST. Fields (" fine screen 1 _ level difference "). The value
It. Subitems (10)=RST. Fields (" fine screen 2 _ level difference "). The value
It. Subitems (11)=RST. Fields (" instantaneous velocity of the water "). The value
It. Subitems (12)=RST. Fields (" 1 _ dissolved oxygen oxidation pool "). The value
It. Subitems (13)=RST. Fields (" 1 "1 _ oxidation pond sludge concentration). The value
It. Subitems (14)=RST. Fields (" 1 _ dissolved oxygen oxidation pool 2 "). The value
It. Subitems (15)=RST. Fields (" 1 _ oxidation pond sludge concentration 2 "). The value
It. Subitems (16)=RST. Fields (2 _ dissolved oxygen oxidation pool "1"). The value
It. Subitems (17)=RST. Fields (" 1 "2 _ oxidation pond sludge concentration). The value
It. Subitems (18)=RST. Fields (" 2 _ dissolved oxygen oxidation pool 2 "). The value
It. Subitems (19)=RST. Fields (" return sludge instantaneous velocity "). The value
It. Subitems (20)=RST. Fields (" match well liquid level "). The value
It. Subitems (21)=RST. Fields (" level "for mud pools). The value
It. Subitems (22)=RST. Fields (" effluent COD "). The value
It. Subitems (23)=RST. Fields (" effluent SS "). The value
It. Subitems (24)=RST. Fields (" water PH "). The value
It. Subitems (25)=RST. Fields (" water ammonia nitrogen "). The value
It. Subitems (26)=RST. Fields (" instantaneous velocity of water "). The value
It. Subitems (27)=RST. Fields (" water traffic "). The value
It. Subitems (28)=RST. Fields (" water traffic "). The value
It. Subitems (29)=RST. Fields (" return sludge traffic "). The value
I=I + 1
RST. Movenext
Loop
RST. Close
The Set of RST=Nothing
The Set of CMD=Nothing
'MsgBox "perform" success, vbOKOnly, "tip"
Con. Close
End the If
The Set of con=Nothing
End Sub

After running the listview control shows the number of rows, satisfy the query conditions, for example, the database has 10 rows of data meet the requirements, according to 1, 2, 3... 10, don't know where there is a problem, a great god help, first aid,

CodePudding user response:

I don't know where I went wrong?
You write code, wrong all don't know where is wrong?

CodePudding user response:

Article one thousand the select statement returns 100000 record?
  • Related