Advanced search page.....

Posted on 2005-04-05
Last Modified: 2010-04-07
Ok, this is my last question today, I promise!

I guess I should start this one off with the simplest question. I have been search all day for some good resources and code for a search page that will access and search and Access Database using OleDb...

So that is question one:
1) Any code, resources or help with creating a simple database search page...

Now question two I guess can only be answered and understood by me once question one is answered...

2)My search page needs to be fairly advances..

I will have a text box a dropdown menu and a button. I want the user to be able to search each database field separately... E.g. I have a timestamp field, and a title field... The user needs to be able top search either the title or by a date...

I also need my search page to act similar to this example:
where only a portion of the word needs to be search with to get results... The more specific the narrower the search...

Can you guys help me find resources to get me started on this search page?

Question by:Nugs
    LVL 7

    Accepted Solution


    please visit the following site whre u can find good artile for database seraching.

    LVL 2

    Author Comment

    ayha... That is the one i listed above...
    LVL 11

    Assisted Solution

    Well, you can list searchable fields either as checkbox or radiobutton list.

    So that user can type wild chars in that text box and say search by "Title" or etc..

    So when you pass the query to access database you can invoke the condition accordingly with the parameter selected in radiobutton list. I guess this should work fine.

    But let me know if you need further more.


    LVL 7

    Expert Comment


    You can put a default item"Any" with dropdown and radiolist with a value of "". If users don't select any item then you can retrive all records.

    LVL 2

    Author Comment

    ayha1999 i have tried to implement the code form ASP101... I wonder if you can help me get it running, i am getting some errors after i modified it...

    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.OleDb" %>
    <script language="VB" runat="server">

          Sub btnSearch_OnClick(sender as Object, e as EventArgs)
                Dim strSearch     As String
                Dim strSQLQuery   As String

                ' Get Search
                strSearch = txtSearch.Text
                ' If there's nothing to search for then don't search
                ' o/w build our SQL Query and execute it.
                If Len(Trim(strSearch)) > 0 Then
                      ' Set up our connection.
                      Dim oleConn As New OleDb.OleDbConnection(System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Conn_Intranet"))

                      ' Set up our SQL query text.
                      strSQLQuery = "SELECT Fld_Title + ' ' + Fld_Body AS Title, Body " _
                            & "FROM TBL_Records " _
                            & "WHERE Fld_Title LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
                            & "OR Fld_Body LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
                            & "ORDER BY Fld_Title;"

                      ' Create new command object passing it our SQL query
                      ' and telling it which connection to use.
                      Dim Comm    As OleDbCommand
                      Comm = New OleDbCommand(strSQLQuery, oleConn)

                      ' Get a DataSet to bind the DataGrid to
                Dim DA As New Ole.OleDbDataAdapter()
                Dim DS As DataSet                  
                      DS = New DataSet()

                      ' DataBind DG to DS
                      dgPaging.DataSource = DS

                      txtSearch.Text = "Enter Search Here"
                End If
          End Sub


    Compiler Error Message: BC30002: Type 'Ole.OleDbDataAdapter' is not defined.

    Source Error:

    Line 30:
    Line 31:                   ' Get a DataSet to bind the DataGrid to
    Line 32:             Dim DA As New Ole.OleDbDataAdapter()
    Line 33:                   DA.selectCommand=Comm

    I tried to convert it to OleDb from SqlClient.... Can you help me geting it running?!
    LVL 2

    Author Comment

    Actualy i fixed the last post and the page displayes:

                Dim DA As New OleDbDataAdapter()
                Dim DS As DataSet                  
                      DS = New DataSet()

    Now when i run a search it give me this:

    Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

    Source Error:

    Line 35:             Dim DS As DataSet                  
    Line 36:                   DS = New DataSet()
    Line 37:                   DA.Fill(DS)
    Line 38:
    Line 39:                   ' DataBind DG to DS

    LVL 2

    Author Comment

    LVL 7

    Expert Comment

    Sorry I was away.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now