Click to See Complete Forum and Search --> : Search a database


RoniR
12-12-2006, 08:34 AM
hey guys i am working on a simple search in my datagrid.The thing is that the user might want to look for a client or its id in the datagrid. MY search is a simple sql statement that goes like select * from client where id like '%23%'
or select * from client where desc like '%RoniR%'.Its working fine but i was wondering if there in another method to do this search.I herd that it takes time (u know seconds are important here).

drallab
12-15-2006, 09:33 AM
I think that query is as good as it's going to get unless you want to use stored procedures which might speed it up by fractions of a second. SQL is faster than code.

On the id, is the id unique to each row? If it is, you could use id= instead of id like '%. That might speed things up a tad.

If the description is the same as the id, you could try it here too.

:)

scottrickman
12-19-2006, 09:40 AM
Does your code get a dataset to populate the data grid initially then have got get additional datasets if / when the user runs the search? If you are searching the SAME data to get filtered rows then: intialise the dataset from the db. put the dataset into cache. When the user performs the search: check the dataset is in the cache (if not re-initialise and put back in the cache), get the dataset from the cache then use the SELECT method on the dataset tables to filter the results. This way you only have one trip to the db and the rest is done in-memory.