Click here to Skip to main content
12,560,658 members (53,129 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked

simple search use multiple words in textbox

, 29 Dec 2005
Rate this:
Please Sign up or sign in to vote.
Using simple code for searching in database


It's always difficult when you want search in database using multiple words. That means we have textbox like "google" and you Enter Some words in textbox then click "go" ,at that time you want to search all the words  in textbox. This is really simple code for searching all tables that use VB.NET code and SQL server.


For who wants to search in the database must know about text split in vb. you can do it in two ways:

1. Declare Stored Procedure in SQL then set parameters in VB then split textbox with split function.

2. Declare function and SQL string without Stored Procedure then search in database with textbox and split function.

Using the code

Here blow I first declare array with two parameters then I split the textbox with "split" function. If you using Stored Procedure you can declare parameter such as "Name" the in the Stored procedure declare SQL command.

Here is the code:

//code behind of webform1.aspx
Dim objparameter As New SqlParameter("@Name", SqlDbType.NVarChar, 50)
Dim a(2) As String
Dim j As Integer
a = txtsearch.Text.Split("", 2)
objparameter.Direction = ParameterDirection.Input
For j = 0 To a.GetUpperBound(0)
objparameter.Value = a(j)
//here is stored Procedure code
@Name nvarchar(50)

select tables from computer where .... like "%"+@Name+"%"


If you have any question, or any comments, please contact me:

Points of Interest

You can build your own simple search engine.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

hamidreza Talebi
Web Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
I am IT Engineering and I write web application for 3 years.I love writing web programming such as,php and java Script.I am know work on XML a new technology for web developer.

You may also be interested in...


Comments and Discussions

Generalsearch engine Pin
bk4code30-May-07 3:35
memberbk4code30-May-07 3:35 
GeneralRe: search engine Pin
jdelito27-Jun-07 21:06
memberjdelito27-Jun-07 21:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161026.1 | Last Updated 29 Dec 2005
Article Copyright 2005 by hamidreza Talebi
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid