开发者

Text search in database column

im using vb 2010 express edition. I have a database (Sql) and a table "students" in the database. It has a data like this:

                StudentId     Name     Surname     Classs

                2266          Mike     Brown       8
                2773          Carol    Smith       6
                2883          Michel   Old         7
                2773          Miray    Edem        6
                27736         Cindy    Temiz       7
                ................................开发者_如何学编程......
                ......................................

there are lots of students. I want to put a search textbox on my form. User will search a student by name. When user presses a key on search textbox, for example "M" a box will appear and shows students which contains "M". (Mike, Michel, Miray) . It will work like google search. is there any way for me to help for this... Please share your ideas...


You should create a customautocomplete class for your textbox and set its autocomplete

Something like:

Dim tbox As New TextBox

Dim aCol As New AutoCompleteStringCollection
For Each student As String In dt.results("students")
  aCol.Add()
Next

tbox.AutoCompleteSource = AutoCompleteSource.CustomSource
tbox.AutoCompleteCustomSource = aCol
tbox.AutoCompleteMode = AutoCompleteMode.SuggestAppend

I prefer VB.NET so I have provided an example in VB.NET as no language was specified.


I always use JQuery's autocomplete: http://docs.jquery.com/Plugins/autocomplete

Build your backend to do the search based on an input string and then have your ui do a json call with the autocomplete to return the results.


Is this a SQL query question or a software question, when you are asking for help? This sounds like a class assignment.

How are you going to be connecting to and querying your database? Are you going to write your query in a stored procedure in the database, or are you going to bind your software objects to the database tables?

Is it a convention at your location to use one kind of data access or query over another?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜