Click here to Skip to main content
15,921,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..I am currently doing a project on Library Management System. how can i compare a value obtained from a textbox to all entries in a database & find the correct match? plz help me out!
Posted
Comments
[no name] 2-Mar-13 13:17pm    
Help with what? Connect to whatever database you are using and run a query against your data using the TextBox.Text. Your question is broad and very vague.

1 solution

Try:
SQL
SELECT * FROM MyTable WHERE ColumnName LIKE '%myCompareString%'
You will probably want code to set the TextBox.Text as a parameter to the SqlCommand object, but that depends on which language you want to use.
 
Share this answer
 
Comments
Madhubala Ganesan 3-Mar-13 3:55am    
No..while issuing a book to a member,i get the member ID as input in a textbox. i need to check if such an ID really exists in my database. i need to compare the member ID from text box to all member IDs in the database. If such an ID exists, book should be issued. If not found, book will not be issued.

"Select * FROM MyTable WHERE" statement cannot be used since i am not using any other parameter to 'select' use for WHERE. i jus need to check a particular column of a whole table with the input from the textbox.
OriginalGriff 3-Mar-13 4:28am    
So you should use
SELECT * FROM MyTable WHERE myColumn=myID
but myID should *definitely* be supplied as a parameter if it is coming from a text box or you rusk SQL Injection attacks. If you get any rows returned then your ID exists.

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