473,396 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

multiple word keyword search in ASP.NET

5
I want to find this book: The history of Columbia's rebels
here is my SQL Query:

Select * from Project (Title Like ("*columbia*rebels*")) OR (Description Like ("*columbia*rebels*"))

this works in Access but not in ASP.NET ... whats wrong?

this is my SQL statement in ASP.net

Select
....
WHERE (Project.Title LIKE '*'+ keyword +'*') OR (Project.Description LIKE '*'+ keyword +'*')

keyword is assigned to a textbox control.....

whats wrong?
Apr 4 '08 #1
3 3316
balabaster
797 Expert 512MB
That would be because * isn't a valid T-SQL wildcard - try replacing it with % and you should be golden.

In addition, if you turn on FullText searching in your SQL database, you can use the contains keyword:

Expand|Select|Wrap|Line Numbers
  1. Select * From MyTable Where Contains(Field1, 'FieldSearchValue') Or Contains(Field2, 'OtherFieldSearchValue)
But, you have to turn FullTextIndexing on your database and on the fields you want FullText indexed in order to use that option.
Apr 4 '08 #2
reyn
5
That would be because * isn't a valid T-SQL wildcard - try replacing it with % and you should be golden.

In addition, if you turn on FullText searching in your SQL database, you can use the contains keyword:

Expand|Select|Wrap|Line Numbers
  1. Select * From MyTable Where Contains(Field1, 'FieldSearchValue') Or Contains(Field2, 'OtherFieldSearchValue)
But, you have to turn FullTextIndexing on your database and on the fields you want FullText indexed in order to use that option.
-----------------------------------------------------------------------------------

I'm using an Access database where do you go to turn fulltext searching on ?
Apr 4 '08 #3
balabaster
797 Expert 512MB
Okay, I've got a chunk of code I use here that works that will do what you're looking for:
Expand|Select|Wrap|Line Numbers
  1. Dim InputData As String = "FindMe"
  2. Dim oCon As New OledbConnection(...ConnectionString...)
  3. oCon.Open
  4. Dim oCmd As New OledbCommand("Select * From Table Where (Field1 Like @FindVal1) Or (Field2 Like @FindVal2)", oCon)
  5. oCmd.Parameters.Add(New OledbParameter("FindVal1", "*"& InputData & "*"))
  6. oCmd.Parameters.Add(New OledbParameter("FindVal2", "*"& InputData & "*"))
  7. Dim oRdr As OledbDataReader = oCmd.ExecuteReader()
  8. If oRdr.HasRows Then
  9.   While oRdr.Read()
  10.     'Do stuff
  11.   End While
  12. End If
  13. oRdr.Close()
  14. oCmd.Dispose()
  15. oCon.Close()
  16. oCon.Dispose()
Sorry - when I read you got it working in access, I guess my brain interpreted it as you were trying to use SQL Server...not ASP.NET
Apr 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Rizyak | last post by:
******************** alt.php.sql,comp databases.ms-sqlserver microsoft.public.sqlserver.programming *********************************** Why doesn't this work: SELECT * FROM 'Events'
3
by: googleboy | last post by:
Hi there. I have defined a class called Item with several (about 30 I think) different attributes (is that the right word in this context?). An abbreviated example of the code for this is: ...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
5
by: JP SIngh | last post by:
Hi All This is a complicated one, not for the faint hearted :) :) :) Please help if you can how to achieve this search. We have a freetext search entry box to allow users to search the...
5
by: anilreddy_3 | last post by:
write a program that search a file for a keyword and replace that keyword with a another word. e.g. search for 'have' and replace with 'had' and list all the changes made ....to the screen...
5
by: mforema | last post by:
Hi Everyone, I want to search records by typing in multiple keywords. I currently have a search form. It has a combo box, text box, Search command button, and a subform. The combo box lists the...
3
by: Moezzie | last post by:
Im going totally crazy over this. Im right now building a verry small solution for searching a mysql-database for up to five keywords. Every file in the database has 2 or more keywords wich the...
0
by: Alex Pavluck | last post by:
Hello. I need to search 6 different fields for a key word. The way I normally query data is in a single field with the critera: Like '*' & & '*'. Is there a way to enter only 1 key word but...
4
by: stateemk | last post by:
I have a table that has about 300 records in it. The table references word documents that are procedures. So, the table has a column for document description, procedure number, type and word...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.