Question Locked

Extracting Variable data from Sql server using VB in C#

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

hi guys, i am working on a project which require me to create a search function which search through my sql database and then display the datas which are selected.

for example
i have a data list with column : name , address, telephone number, age, gender.

i would need to type in the name and then search and display all data with the same name.

since the name that i type into the searchbox is everchanging, how would i be able to put it into the "WHERE NAME =" command of the sql

2 replies

by tony hopkinson

If you had an edit box to take the target name.

A grid to show the answer, bound to a parameterised query.

Then on each change (don't forget to deal with blank entry)
Just set the parameter value to the content of the edit box.

You should not be building sql from user input, look up sql injection.

You would be beter off with like rather than =, that say as the user types, the list narrows down. Of course it you have a lot of data that might get expensive, there are a few ways of dealing with that, from adding a get button and putting the code in it's onclick to paging and even threading.

This discussion is closed to new replies.