I'd like to know if there is something, such as a built-in function, that could help me.
The best idea I have is to create some sort of node tree and work with that but there has to be a better way.
I need to do it in C# or in MS SQL. Any kind of help is much appreciated!
YOu should either write your request to a platform group, e.g. WIndows Applications with C# or Web.Applications with C#, this mainly has nothing do to with SQL Server, more with the frontend you will create.
Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||Actually I implemented it with SQL and it works rather well I must admit.
It returns:
"Emma Strandberg"
Since there is a Firstname Emma and her last name is Strandberg
SQL Code
SET @.match = 'Em'
/* SET NOCOUNT ON */
SELECT (Firstname + ' ' + Lastname) AS Wholename
FROM CMR_Arrivals
WHERE SUBSTRING(Lastname, 1, LEN(@.match)) = @.match
OR SUBSTRING(Firstname, 1, LEN(@.match)) = @.match
And it will also return 'Bill Emerson'
However, you asked about
. Your 'solution' has absolutely nothing to do with auto-completion.
Automatic text completion
Yes, your search 'kinda' works to find the data you seek. One consideration is that by wrapping the column with a function, substring(), you guarantee that the process will NOT be able to efficiently use indexing. On a large table, that can be a bit slow.
You may wish to refer to Books Online about the use of Wildcards in search criteria.
See Books Online, Topics:
Wildcards LIKE 'Pattern Matching in Search Conditions'|||The query will be used with AJAX AutoComplete(Extender Toolkit) and the results will be limited hence the returned value wont be so many.
You are right in that it's not exactly what I was originally looking for!
Peter Ritchie (MVP) suggested:
" Sounds like what you want is AutoComplete, e.g. TextBox.AutoCompleteCustomSource.
Ken Getz has a good overview of the feature here: http://code-magazine.com/Article.aspx?quickid=0509111"
Where I replied:
" Sounds like something I was looking for BUT I was going to use the AutoCompleteExtender in the ASP.NET AJAX Toolkit.
Now I don't mind skipping the AJAX control but when looking at a Textbox the only option I have is AutoCompleteType.
None of the other functions such as AutoCompleteCustomSource are available.
I have .Net 2.0 installed and does say TextBox 2.0.0.0 .Net when holding the mouse over the control in VS2005.
Am I missing something here?
"
Typically, he way 'autocomplete' functionality works is that a set of data has been retrieved from the database, as as the user types into the textbox control, the textchanged event is used to update the filter on the data.
Alternatively, on each keystroke, the textchanged event could be used to re-run the query to the data server.
BUT that is a very bad idea in terms of system performance.
No comments:
Post a Comment