贵州毕节韭菜坪:asp.net 多条件查询问题,再线等,谢谢

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 06:42:00
我用条件"变电站号"、“变压器号”和“起始日期”和“终止日期”这四个条件去查询某段时间的纪录,可是查不出来,datagrid的数值不变,以下是我的代码,textbox1.text是起始日期,textbox2.text是终止日期。问哪里出了问题,非常感谢。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim a As Integer = CInt(DropDownList1.SelectedItem.Value)
Dim b As Integer = CInt(DropDownList2.SelectedItem.Value)

Dim lookup As String
If TextBox1.Text = "" And TextBox2.Text = "" Then
lookup = "select * from History_sp where transSubStationNo=" & a & " and TrsNo=" & b
Else

lookup = "select * from History_sp where transSubStationNo=" & a & " and TrsNo=" & b & " and date between # ' & textbox1.Text & '# And #'&textbox2.Text&'#"

End If
adp = New OleDbDataAdapter(lookup, conn)
Dim ds4 As New DataSet

adp.Fill(ds4)
DataGrid1.DataSource = ds4
DataGrid1.DataBind()
Catch ex As OleDbException
Response.Write("<script language=javascript>alert('" + ex.Message.ToString + "')</script>")
End Try
数据库中的日期是日期类型。

lookup = "select * from History_sp where transSubStationNo=" & a & " and TrsNo=" & b & " and date between # ' & textbox1.Text & 'And' & textbox2.Text&'"
这样试试