473,386 Members | 1,883 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,386 software developers and data experts.

Multi-parameter stored procedure (query in Access)

Is it possible to use a multi-parameter query in .NET

Here's the method
Public Function SearchCatalog(ByVal searchString As String, ByVal allWords As String) As OleDbDataReade

' Create the connection objec
Dim connection As New OleDbConnection(connectionString
Dim command As New OleDbComman

' We guard agains bogus values here - if we receive anythin
' different than "TRUE" we assume it's "FALSE
If allWords.ToUpper = "TRUE" The
' Create and initialize the command object and search all word
command.CommandText = "SearchCatalogAllWords
command.Connection = connectio
command.CommandType = CommandType.StoredProcedur
Els
' Create and initialize the command object and search any word
command.CommandText = "SearchCatalogAnyWords
command.Connection = connectio
command.CommandType = CommandType.StoredProcedur
End I

' We eliminate separation character
searchString = searchString.Replace(",", " "
searchString = searchString.Replace(";", " "
searchString = searchString.Replace(".", " "

' We create an array which contains the word
Dim words() As String = Split(searchString, " "

' wordsCount contains the total number of word
Dim wordsCount As Integer = words.Lengt
' index is used to parse the list of word
Dim index As Integer =
' this will store the total number of added words
Dim addedWords As Integer =

' We allow a maximum of 5 word
While addedWords < 5 And index <
' We add the @searchWord parameters her
If addedWords < wordsCount The
addedWords +=
' Add an input parameter and supply a value for i
command.Parameters.Add("@searchWord" + addedWords.ToString, words(index)
Els
addedWords +=
' Add a blank input paramete
command.Parameters.Add("@searchWord" + addedWords.ToString, ""
End I
index +=
End Whil
' Open the connectio
connection.Open(

' Return a SqlDataReader to the calling functio
Return command.ExecuteReader(CommandBehavior.CloseConnect ion
End Functio

Here is the query
SELECT Product.ProductID, Product.Name, Product.Description, Product.SKU, Product.Price, Product.ImagePat
FROM Produc
WHERE (((Product.Name) Like "*"+[@searchWord1]+"*")) OR (((Product.Description) Like "*"+[@searchWord1]+"*"))AND (((Product.Name) Like "*"+[@searchWord2]+"*")) OR (((Product.Description) Like "*"+[@searchWord2]+"*")) AND (((Product.Name) Like "*"+[@searchWord3]+"*")) OR (((Product.Description) Like "*"+[@searchWord3]+"*")) AND (((Product.Name) Like "*"+[@searchWord4]+"*")) OR (((Product.Description) Like "*"+[@searchWord4]+"*")) AND (((Product.Name) Like "*"+[@searchWord5]+"*")) OR (((Product.Description) Like "*"+[@searchWord5]+"*"))

Jul 21 '05 #1
0 1696

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
2
by: Aussie Rules | last post by:
Hi, I have a site that Iwant to either display my text in english or french, based on the users prefernces ? I am new to webforms, but I know in winforms, this is pretty easy with a resource...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.