Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Advanced search page.....

Posted on 2005-04-05
8
Medium Priority
?
279 Views
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:
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
Comment
Question by:Nugs
  • 4
  • 3
8 Comments
 
LVL 7

Accepted Solution

by:
ayha1999 earned 900 total points
ID: 13720859
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
 
LVL 2

Author Comment

by:Nugs
ID: 13721346
ayha... That is the one i listed above...
0
 
LVL 11

Assisted Solution

by:sachiek
sachiek earned 600 total points
ID: 13724088
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Expert Comment

by:ayha1999
ID: 13724943
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
 
LVL 2

Author Comment

by:Nugs
ID: 13738636
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
 
LVL 2

Author Comment

by:Nugs
ID: 13738753
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
 
LVL 7

Expert Comment

by:ayha1999
ID: 13742081
Sorry I was away.

ayha
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 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