Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi There,

I am trying to make an application where if the user enters a number in a text box and then presses a button then it will search my sql database file data.mdf and will display the name of the person of that particular unique no. entered in the text box.

Can Anyone please tell me the coding for the button.

I am a Newbie so please try to help...


THANKS IN ADVANCE
Posted

Try searching for some articles on Google [^]or the articles in CodeProject.

This one[^] looks like a good start for you.
 
Share this answer
 
You need SQL to query the database.
For example in your case : SELECT NameOfThePerson WHERE ID=YourTextBoxValueAsInteger

For executing the query you need coding in your application, do some thing like open the database, query it and close.

If you search "C# SQL QUERY" in some engine you find a lot of examples ...
 
Share this answer
 
Comments
Kschuler 9-Mar-11 11:43am    
You should also mention, however, that it's not good practice to just use WHERE ID=YourTextBoxValueAsInteger because it can lead to problems with SQL Injection attacks. Best practice would be to use parameters instead.
Or...maybe this can get you started?

VB
' If search box is empty
If SearchBox.Text = "" Then
   ' Bring up all names
   Me.BindingSource1.Filter = "UniqueID like '" & "%" & "'"
Else
   ' Bring up name being searched for
   Me.BindingSource1.Filter = "UniqueID like '" & "%" & SearchBox.Text & "%" & "'"
End If


Not sure this is what you are looking for, but here is an idea.

[Modified to specify the language for the pre block so that it will be color-formatted correctly]
 
Share this answer
 
v2

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