473,324 Members | 2,239 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,324 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 1692

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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.