Hopefully this will give you a clue .....it is very simple example but it helps me learing how to create an advanced search page. good luck
Imports System.Data
Imports System.Data.OracleClient
Imports System.Configuration.ConfigurationManager
Partial Class ItemSearch
Inherits System.Web.UI.Page
Sub SearchButton_Click(ByVal sender As Object, ByVal e As EventArgs)
'Dim oOracleConn As OracleConnection
Dim connectionString As String = ConnectionStrings("ConnectionString").ConnectionString
Dim oOracleConn As OracleConnection = New OracleConnection(connectionString)
'This will make sure both english and metric units are not selected at the same time.
If (ck2005.Checked And ck2001.Checked) Or (ck2000.Checked And ck2001.Checked) Or (ck2005.Checked And ck2001.Checked And ck2000.Checked) Then
lblMixUnit.Text = "You can not select both English and Metric units at the same time"
gvItemSearch.Visible = False
lblTotal.Visible = False
lblMixUnit.Visible = True
Else
gvItemSearch.Visible = True
lblTotal.Visible = True
lblMixUnit.Visible = False
Dim strWhereClause As String = ""
'converts the input value to uppercase
strWhereClause = Trim(UCase(txtItem.Text))
Dim strSQLforGrid As String = "SELECT Item_Number ""Item Number"" , "
strSQLforGrid = strSQLforGrid & " Short_Description ""Short Description"", LONG_DESCRIPTION ""Long Description"",UNIT_NAME ""Unit Name"" , "
strSQLforGrid = strSQLforGrid & " PLAN_UNIT_DESCRIPTION ""Plan Unit Description"", SPEC_YEAR ""Spec Year"" "
strSQLforGrid = strSQLforGrid & " FROM ITEMSEARCH"
strSQLforGrid = strSQLforGrid & " WHERE ITEM <> '2999509/00001' AND IOBSELET='N' AND "
'search by either description or units
If rdDes.Checked Then
strSQLforGrid = strSQLforGrid & "upper(LONG_DESCRIPTION) Like :vendID"
ElseIf rdUnit.Checked Then
strSQLforGrid = strSQLforGrid & "upper(PLAN_UNIT_DESCRIPTION) like :vendID"
ElseIf rdNumber.Checked Then
strSQLforGrid = strSQLforGrid & "upper(Item_Number ) like :vendID"
End If
'checks with spec year(s) is/are selected
If (ck2005.Checked And ck2000.Checked) Then
strSQLforGrid = strSQLforGrid & " and (SPEC_YEAR = '05' or SPEC_YEAR= '00')"
ElseIf ck2000.Checked Then
strSQLforGrid = strSQLforGrid & " and SPEC_YEAR = '00'"
ElseIf ck2001.Checked Then
strSQLforGrid = strSQLforGrid & " and SPEC_YEAR = '01'"
ElseIf ck2005.Checked Then
strSQLforGrid = strSQLforGrid & " and SPEC_YEAR = '05'"
Else : strSQLforGrid = strSQLforGrid & " and SPEC_YEAR = '05'"
End If
strSQLforGrid = strSQLforGrid & " order by Item_Number asc,LONG_DESCRIPTION asc "
'Remove next line prior to deployment
'Response.Write("strSQLforGrid = <br/>" & strSQLforGrid & "<hr/>")
Dim myCommand3 As OracleCommand = New OracleCommand(strSQLforGrid, New OracleConnection(GetConnectionString()))
myCommand3.Parameters.Clear() 'Clear the parameters
myCommand3.Parameters.AddWithValue(":vendID", "%" & strWhereClause & "%")
Dim myAdapter3 As New OracleDataAdapter(myCommand3)
Dim myDataSet As New DataSet
myAdapter3.Fill(myDataSet, "VendorSearch")
gvItemSearch.DataSource = myDataSet
gvItemSearch.DataBind()
lblTotal.Text = "Total :" + gvItemSearch.Rows.Count.ToString() + " record(s) found"
End If
End Sub
Function GetConnectionString() As String
Return ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
End Function
End Class