Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In the database how to search particular column like search by name or search by Email
please help..
Posted
Comments
[no name] 8-Oct-12 2:44am    
using what control u want to search..means is it combobox or textbox..????

You have the WHERE clause that you can use with commands such as LIKE or BETWEEN that you can use to do a filter.
For e.g.
select * from myTable where email like 'ABC.COM'

In addition, wild card characters[^] like % and ? provide additional filtering criteria for a query.
 
Share this answer
 
Issue a T-SQL query in an SQLCommand[^] with a LIKE[^] operator.
 
Share this answer
 
It is easy to use drop down list and a textbox, in the drop down list select the column name and in the textbox you write the string to be searched.
 
Share this answer
 
create combobox that contains column names,
a textbox for value to search,
a button 'Search'

in btnSearch click event... use below query
C#
"select * from myTable where " + comboboxColumnList.SelectedText + " like '%" + txtbox1.text + "%'"

Happy Coding!
:)
 
Share this answer
 
Hello,

All the above solutions will work to search from database.
If you want to see example then see the below link and download the code, it might be help you.

http://www.c-sharpcorner.com/uploadfile/abhikumarvatsa/searching-any-record-from-database-in-Asp-Net/[^]
http://www.dreamincode.net/forums/topic/221470-to-search-the-data-from-database-using-aspnetc%23/[^]
http://www.aspnettutorials.com/tutorials/database/searchwithstring-csharp.aspx[^]

Thanks,
Viprat
 
Share this answer
 
jayaprakash..u want to search a single column right..then u can use..same as wat others have suggested..
with little modification..
try this,

select colname from tablename where colname=@colname

This searches only colname..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900