Caching

bghanim

Active member
Joined
Dec 5, 2006
Messages
40
Location
Abu Dhabi - UAE
Programming Experience
1-3
Hello all,
I need to do caching with my application i.e. I have a textBox text changed event, each time the user enters a character, a connection to the sql server is done.

Instead of connecting to the sql server each time the user search an employee name, I stored the data of employee table in my employee Object, which is an instance of a class that I've defined which store for example employee name in array of strings. Once the first request is done, the application should retrieve employees information from the data stored in the that object.

The search method is based on the employee name by using the like clause of a select statment i.e. " where full_name like %' " & me.textBox1.text & " ' "

My question is: how can I perform the same operation (like clause) on an array of strings.

Regards,
Baha A. Ghanim
 
Caching is a term usually applied to web application yet this post is in the Windows Forms section.

Is this a winform or web app?

If it is a winform, a possible solution would be to retrieve the data from the database into a dataset or dataTable. Bind whatever UI control you are using to display the results to the defaultview of the dataTable then in the text changed event handler of the textbox, set the RowFilter property of the default view to the select statement you have shown above without 'where' at the beginning.
 
Here is how I do it,


VB.NET:
   For i As Integer = 0 To Me.cacheObj.cacheLengh - 1
            If Me.cacheObj.patientsNames(i).ToUpper[COLOR=blue] [B]Like [/B][/COLOR]Me.TextBox9.Text.ToUpper & "*" Then
             ' do something here
            End If
   Next
 
Back
Top