• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

Advanced search page.....

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:
http://aspnet.asp101.com/samples/db_search.aspx
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?

Nugs
0
Nugs
Asked:
Nugs
  • 4
  • 3
2 Solutions
 
ayha1999Commented:
Hi,

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

http://www.asp101.com/samples/db_search_aspx.asp

ayha
0
 
NugsAuthor Commented:
ayha... That is the one i listed above...
0
 
sachiekCommented:
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.

Sachi


0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
ayha1999Commented:
HI,

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.

ayha
0
 
NugsAuthor Commented:
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()
                  DA.selectCommand=Comm
                  
            Dim DS As DataSet                  
                  DS = New DataSet()
                  AD.Fill(DS)

                  ' DataBind DG to DS
                  dgPaging.DataSource = DS
                  dgPaging.DataBind()

                  OleConn.Close()
            Else
                  txtSearch.Text = "Enter Search Here"
            End If
      End Sub

</script>
----------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------
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?!
0
 
NugsAuthor Commented:
Actualy i fixed the last post and the page displayes:

----------------------------------------------------------------------------------
...
            Dim DA As New OleDbDataAdapter()
                  DA.selectCommand=Comm
                  
            Dim DS As DataSet                  
                  DS = New DataSet()
                  DA.Fill(DS)
...
----------------------------------------------------------------------------------

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
-----------------------------------------------------------------------------------

????
0
 
ayha1999Commented:
Sorry I was away.

ayha
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now