Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to search a database with a stored procedure?

Reply
Thread Tools

how to search a database with a stored procedure?

 
 
wilco
Guest
Posts: n/a
 
      08-04-2003
hello,

can any one tell me how to create a stored procedure that is beable to
search a table, or more table's and can make use of wildcards?
i just made somthing like this,:
SELECT * FROM tblUsers WHERE Adress LIKE '* Value from user how wants to
search the database *'
but I don't know where to place the @??? for the input
i also wants to make the user can select witch table and field he want's to
search.

thanks!!


 
Reply With Quote
 
 
 
 
Jerry III
Guest
Posts: n/a
 
      08-04-2003
And when you do it like this someone will sumbit "%' GO DELETE tblUsers --"
in your input box and wipe out your table (if the database user has enough
privileges to do so).

A better solution is to use the command object, like this:

OleDbCommand cmd = new OleDbCommand();

cmd.CommandText = "SELECT * FROM [tblUsers] WHERE [Address] LIKE @address";
cmd.Parameters.Add("@address", "%" + txtAddress.Text + "%");

Jerry

"David Wier" <> wrote in message
news:%...
> Dim sAddress as String
> sAddress=txtAddress.text
> SQL = "SELECT * FROM tblUsers WHERE Adress Like '%" & sAddress & "%'"
>
> Put the % sign on the front and at the end, in order to search the entire
> field
>
> Check out this 2 Part Tutorial on Parameterized Queries:
> http://aspnet101.com/aspnet101/tutorials.aspx?id=1
>
> LIKE is covered in Part 2
>
> David Wier
> http://aspnet101.com
> http://aspexpress.com
>
>
> "wilco" <> wrote in message
> news:bgm62m$oou$...
> > hello,
> >
> > can any one tell me how to create a stored procedure that is beable to
> > search a table, or more table's and can make use of wildcards?
> > i just made somthing like this,:
> > SELECT * FROM tblUsers WHERE Adress LIKE '* Value from user how wants to
> > search the database *'
> > but I don't know where to place the @??? for the input
> > i also wants to make the user can select witch table and field he want's

> to
> > search.
> >
> > thanks!!
> >
> >

>
>



 
Reply With Quote
 
 
 
 
Xavier MT
Guest
Posts: n/a
 
      08-05-2003
Can I ask what is the difference?

I just want to understand it....

"Jerry III" <> wrote in message
news:%23Z1C%...
> And when you do it like this someone will sumbit "%' GO DELETE

tblUsers --"
> in your input box and wipe out your table (if the database user has enough
> privileges to do so).
>
> A better solution is to use the command object, like this:
>
> OleDbCommand cmd = new OleDbCommand();
>
> cmd.CommandText = "SELECT * FROM [tblUsers] WHERE [Address] LIKE

@address";
> cmd.Parameters.Add("@address", "%" + txtAddress.Text + "%");
>
> Jerry
>
> "David Wier" <> wrote in message
> news:%...
> > Dim sAddress as String
> > sAddress=txtAddress.text
> > SQL = "SELECT * FROM tblUsers WHERE Adress Like '%" & sAddress & "%'"
> >
> > Put the % sign on the front and at the end, in order to search the

entire
> > field
> >
> > Check out this 2 Part Tutorial on Parameterized Queries:
> > http://aspnet101.com/aspnet101/tutorials.aspx?id=1
> >
> > LIKE is covered in Part 2
> >
> > David Wier
> > http://aspnet101.com
> > http://aspexpress.com
> >
> >
> > "wilco" <> wrote in message
> > news:bgm62m$oou$...
> > > hello,
> > >
> > > can any one tell me how to create a stored procedure that is beable to
> > > search a table, or more table's and can make use of wildcards?
> > > i just made somthing like this,:
> > > SELECT * FROM tblUsers WHERE Adress LIKE '* Value from user how wants

to
> > > search the database *'
> > > but I don't know where to place the @??? for the input
> > > i also wants to make the user can select witch table and field he

want's
> > to
> > > search.
> > >
> > > thanks!!
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Database Database Database scott93727@gmail.com Computer Information 0 09-27-2012 02:43 AM
DataBase DataBase DataBase DataBase scott93727@gmail.com Computer Information 0 09-26-2012 09:40 AM
| SEO , Search Engine Optimizer, SEARCH OPtiMIzAtIoN with SeaRch OPtiMizer optimizer.seo@gmail.com Digital Photography 0 04-22-2007 04:20 AM
search within a search within a search - looking for better way...my script times out Abby Lee ASP General 5 08-02-2004 04:01 PM
Search attachments stored in SQL Server Satish Appasani ASP .Net 0 06-26-2003 07:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57