Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Search_String As String = ""
Dim i As Integer
For i = 0 To (CheckBoxList2.Items.Count - 1)
If (CheckBoxList2.Items(i).Selected) Then
Search_String = Search_String & " [PowerSupply] LIKE '" & CheckBoxList2.Items(i).Text & "' or "
Search_String = Mid(Search_String, 1, Len(Search_String) - 0)
If DropDownList1.SelectedValue <> "ALL" Then
Search_String = Search_String & " AND [Density]='" & DropDownList1.SelectedValue & "'" & " AND [Configuration]='" & CheckBoxList1.SelectedValue & "'"
SqlDataSource4.SelectCommand = "SELECT * FROM [LowPower] where [Density]='" & DropDownList1.SelectedValue & "' AND [Configuration]='" & CheckBoxList1.SelectedValue & "' AND '" & Search_String & "'"
GridView1.DataSourceID = "Sqldatasource4"
End If
End If
Next
If (Search_String = "") Then
Label1.Text = "未選取Configuration"
End If
Dim SQLTXT As String = "SELECT * FROM [LowPower] where [Density]='" & DropDownList1.SelectedValue & "' AND [Configuration]='" & CheckBoxList1.SelectedValue & "' AND '" & Search_String & "'"
Response.Write(SQLTXT)
End Sub
程式出現錯誤,不知道是哪邊錯了
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20120106173326R2I&fumcde=FUM20041006161839LRJ#BRD20120106184654D1F
For i = 0 To (CheckBoxList2.Items.Count - 1)
If (CheckBoxList2.Items(i).Selected) Then
Search_String = Sea...(恕刪)
For i = 0 To (CheckBoxList2.Items.Count - 1)
If (CheckBoxList2.Items(i).Selected) Then
Search_String = Search_String & " [PowerSupply] LIKE '" & CheckBoxList2.Items(i).Text & "' or "
Search_String = Mid(Search_String, 1, Len(Search_String) - 0)
If DropDownList1.SelectedValue <> "ALL" Then
Search_String = Search_String & " AND [Density]='" & DropDownList1.SelectedValue & "'" & " AND [Configuration]='" & CheckBoxList1.SelectedValue & "'"
SqlDataSource4.SelectCommand = "SELECT * FROM [LowPower] where [Density]='" & DropDownList1.SelectedValue & "' AND [Configuration]='" & CheckBoxList1.SelectedValue & "' AND '" & Search_String & "'"
GridView1.DataSourceID = "Sqldatasource4"
End If
End If
Next
你為何要重複 ? WHERE 內容(Search_String)
& CheckBoxList2.Items(i).Text & "' or "
還有 用 OR 就是通通出來
我們是 全球最大開碼 ERP
Skype: Adempiere/Compiere
技術轉移顧問
Albert