Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to clear cache

Status
Not open for further replies.

josie2007

Technical User
Apr 14, 2007
90
US
I am putting mydata set in cache and I would like to clear it when I change the selection from the dropdown.right now even if I select different value it won't change. I have to close the application and open it again

Sub BindLetData()

Dim Source As DataView
Source = Cache("MyItemDataSet")

If Source Is Nothing Then

gvProp.PageSize = pageSize.SelectedValue
Dim connectionString As String = ConnectionStrings("ConnectionString").ConnectionString
Dim oOracleConn As OracleConnection = New OracleConnection(connectionString)
oOracleConn.Open()

Dim cmdPropItems As OracleCommand = New OracleCommand()
With cmdPropItems
.Connection = oOracleConn
.CommandText = "ITEMCUSTOMPAGING"
.CommandType = CommandType.StoredProcedure
.Parameters.Clear()
.Parameters.Add(New OracleParameter("p_desc", OracleType.VarChar)).Value = Trim(txtDescription.Text)
.Parameters.Add(New OracleParameter("p_letting", OracleType.DateTime)).Value = ddLetting.SelectedValue
.Parameters.Add(New OracleParameter("p_letting1", OracleType.DateTime)).Value = ddLetting1.SelectedValue
.Parameters.Add(New OracleParameter("i_results", OracleType.Cursor)).Direction = ParameterDirection.Output
End With

Dim adPropItems As New OracleDataAdapter(cmdPropItems)
Dim dsPropItems As New DataSet
adPropItems.Fill(dsPropItems, "PropItems")

If dsPropItems.Tables("PropItems").Rows.Count.ToString = "0" Then
lblView.Visible = False
lblView1.Visible = False
lblView.Text = String.Format("<i>{0} records matched your search keywords.</i>", dsPropItems.Tables("PropItems").Rows.Count.ToString)

Else
lblView.Text = String.Format("<i> Total Records Found : {0} </i>", dsPropItems.Tables("PropItems").Rows.Count.ToString)

End If
Source = New DataView(dsPropItems.Tables("PropItems"))
Cache("MyItemDataSet") = Source
End If

gvProp.DataSource = Source
gvProp.DataBind()

End Sub
 
thank you for the response. I have two dropdowns ddLetting and ddLetting1 where the users can select different date and I just only want to clear cache when a user select a different date. How can I do this. thanks
 
If the data is going to change often, then cache is not what you want to use.
 
thank you for your response again. so, what shall I use then?
 
This data is going to be shared by a large group of people to see what construction items was used for the past project.
 
In that case the Cache may be a good place to store it (unless you expect the data to change a lot in which case it will be better to just query the database each time). If you are going to use the Cache, follow jbenson001's advice above.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
If you are sharing this across users, then when one user changes the selection, the cache clears and is reset for all users. that doesn't make sense to me. Am I missing something? I might suggest that you set a cache for each possible selection from the first dropdown or cache based on user.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top