Public Sub showbb()
Dim i As Integer
Dim j As String
Dim k As String
Dim X As Date
Dim time1 As String
Dim time2 As String
Dim time3 As String
Dim Y As String
Dim Rs As New ADODB.Recordset '定義連接資料庫的ADO變數
time1 = Format(datetime.Value, "yyyy-MM-dd")
X = CDate(time1)
Y = " '" + time1 + "'"
For i = 0 To 23
If i < 10 Then
j = CStr(i)
time2 = "0" & j & ":" & "00" & ":" & "00"
End If
If i >= 10 Then
j = CStr(i)
time2 = j & ":" & "00" & ":" & "00"
End If
If i + 1 < 10 Then
k = CStr(i + 1)
time3 = "0" & k & ":" & "00" & ":" & "00"
End If
If i + 1 >= 10 Then
k = CStr(i + 1)
time3 = k & ":" & "00" & ":" & "00"
End If
openDB1 '打開IFIX_DATA資料庫,該函式在后面有定義
CmdTruck.ActiveConnection = conn
CmdTruck.CommandText = "select data.PH,data.PAH,data.濁度 from data where convert(char(10),時間,120)= 'time1'and convert(char(8),時間,108) between 'time2' and 'time3'"
Set Rs = CmdTruck.Execute
這樣寫查詢不到資料,當把time1,time2,time3換成準確值如:time1改成2020-02-28,time2改成14:00:00,time3改成15:00:00時可以查詢到資料,請幫忙看看錯在哪里?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/16887.html
標籤:網絡編程
上一篇:找 課 堂
下一篇:新手求助
