我开发系统的时候,需要写一个多条件的查询语名,提示错误码是"falseandtrue"
请各位高手帮我指点一下.我想跟据 >"Txt开始时间" 而 "Txt结束时间" 查询Dim Cnn As ADODB.Connection
Dim Rs As ADODB.Recordset
Private Sub Cmd查询_Click()
Dim Str As String
Dim Temp As String
Dim temp1 As String
Dim temp2 As String
Set Cnn = New ADODB.Connection
Cnn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=金光油脂;Data Source=pakbai"Cnn.Open
Cnn.CursorLocation = adUseClient
Set Rs = New ADODB.Recordset
If Trim(Txt油罐编号.Text) <> "" Then
Temp = "tkid=" & "'" & Trim(Txt油罐编号.Text) & "'"
If Str <> "" Then
Str = Str + " and " + Temp
Else
Str = Temp
End If
End If If Trim(Txt开始时间.Text) <> "" And Trim(Txt结束时间.Text) <> "" Then
temp1 = "timestart>=" & "'" & Trim(Txt开始时间.Text) & "'"
temp2 = "timestart<=" & "'" & Trim(Txt结束时间.Text) & "'"
Temp = (Temp > temp1) & "And" & (Temp < temp2)
If Str <> "" Then
Str = Str + " and " + Temp
Else
Str = Temp
End If
End If
Str = "select * from Tankstore where " & Str
Rs.Open Str, Cnn, adOpenDynamic, adLockOptimistic
Set DG.DataSource = Rs
End Sub
请各位高手帮我指点一下.我想跟据 >"Txt开始时间" 而 "Txt结束时间" 查询Dim Cnn As ADODB.Connection
Dim Rs As ADODB.Recordset
Private Sub Cmd查询_Click()
Dim Str As String
Dim Temp As String
Dim temp1 As String
Dim temp2 As String
Set Cnn = New ADODB.Connection
Cnn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=金光油脂;Data Source=pakbai"Cnn.Open
Cnn.CursorLocation = adUseClient
Set Rs = New ADODB.Recordset
If Trim(Txt油罐编号.Text) <> "" Then
Temp = "tkid=" & "'" & Trim(Txt油罐编号.Text) & "'"
If Str <> "" Then
Str = Str + " and " + Temp
Else
Str = Temp
End If
End If If Trim(Txt开始时间.Text) <> "" And Trim(Txt结束时间.Text) <> "" Then
temp1 = "timestart>=" & "'" & Trim(Txt开始时间.Text) & "'"
temp2 = "timestart<=" & "'" & Trim(Txt结束时间.Text) & "'"
Temp = (Temp > temp1) & "And" & (Temp < temp2)
If Str <> "" Then
Str = Str + " and " + Temp
Else
Str = Temp
End If
End If
Str = "select * from Tankstore where " & Str
Rs.Open Str, Cnn, adOpenDynamic, adLockOptimistic
Set DG.DataSource = Rs
End Sub
temp2 = "timestart<=" & "'" & Trim(Txt结束时间.Text) & "'"
Temp = (Temp > temp1) & "And" & (Temp < temp2)