C# - Cache Is Not Invalidated After Table Update Using The SqlCacheDependency?
Apr 28, 2010
I have been trying to get SqlCacheDependency working. I think I have everything set up correctly, but when I update the table, the item in the Cache isn't invalidated.
I enabled the Service Broker for the Sandbox database.I have placed the following code in the Global.asax file. I also restart IIS to make sure it is called.
void Application_Start(object sender, EventArgs e) {
SqlDependency.Start(ConfigurationManager.ConnectionStrings["SandboxConnectionString"].ConnectionString);
}
I have placed this entry in the web.config file:
<system.web>
<caching>
<sqlCacheDependency enabled="true" pollTime="10000">[code]....
I call this code to put the item into the cache:
protected void CacheDataSetButton_Click(object sender, EventArgs e) {
using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SandboxConnectionString"].ConnectionString))[code].....
Then I bind the GridView with this code:
protected void BindGridViewButton_Click(object sender, EventArgs e) {
if (Cache["Pets"] != null) {
GridView1.DataSource = Cache["Pets"] as DataSet;
GridView1.DataBind();
}
}
Between attempts to DataBind the GridView, I change the table's values expecting it to invalidate the Cache["Pets"] item, but it seems to stay in the Cache indefinitely.
View 1 Replies
Similar Messages:
Feb 2, 2011
I am using sqlCacheDependency, and usually upon any changes in the database cache items get deleted automatically. In my case everything works allright, but I had to buy a new laptop and I moved the same exact database and the same exact webapplication to the new laptop. Unfortunately, on my new machine the cache items remain in cache upon data updates on the database.
I have enabled servicebroker on the database, and started it in the application_start event in my webapplication. I also ran the following:
GRANT SUBSCRIBE QUERY NOTIFICATIONS
TO "Naji-pcNaji"
The differance I see on my laptop from my other machine is that the database is named (local). Naji-pc is the name of my machine.
View 1 Replies
Feb 9, 2010
I think it is a problem that SqlCacheDependency may invalidate a cache item while it is being set:
function getCacheItem()
if cacheitem is empty
cacheitem = something
AND AT THIS POINT SqlCacheDependency INVALIDATES THE cacheitem
end if
return cacheitem
end function
how can we prevent this? Is it somehow possible to specify a ReaderWriterLockSlim for the SqlCacheDependecy to use?
View 1 Replies
Sep 2, 2010
I need to use caching in my project. The problem is that, When page is firstly load ı cached a dataset. Then after after I update or insert a new record in table. my dataset returns from the cached records.
View 2 Replies
Jan 4, 2010
In my database I have altered stored procedure AspNet_SqlCacheRegisterTableStoredProcedure that is used for SqlCacheDependency to register tables that are in different schema then dbo (original procedure allows only tables for dbo schema).
That works, but I can't register same table name for different schemas, for example dbo.MyTable and MySchema.MyTable.In column tableName in table AspNet_SqlCacheTablesForChangeNotification there are only table names without schemas.
Is it possible to register same table names and different schemas?
View 1 Replies
May 7, 2015
I am binding repeater control for mega menu, its working fine but i want to repeater do not load every time from database ,it load when any change or add in database ....
View 1 Replies
Jan 15, 2010
And if so is there an example in vb .net? I want to add a linq result to the cache and then allow a mvc post to search the cache for better performance...every way I implement it I receive an object not referenced error...
I'm confused, maybe I shouldn't be doing it this way but the mvc post will be checking up to 2000 records and it would seem best not to have it querying the database everytime.
View 4 Replies
May 9, 2010
I have a page that has a grid view.
The user selects a person from a dropdown list and then clicks a button that adds the users info as
a new row in the grid.
Adding the new row involves doing an insert and rebinding the grid which is a slow process.
How do I use the cache to see the grid update right away?
View 5 Replies
Apr 21, 2010
I have a DataTable with about 10,000 rows in it.
I would like to store this data once for aspx page. When the user selects different options in the page, data is further selected from the already stored DataTable.
I tried using the ViewState, but as soon as the data grows beyond 100 rows, performance degrades.
View 1 Replies
Jan 17, 2010
U are caching a list of items, then Add or update or delete method called. Approach 1)
A- Do the data change at the database. If success do B, C
B- Remove the entire list from the Cache.
C- Re-Cache the list on first read.
Approach 2)
A- Do the data change at the database, If success do B
B- Do the same change at the cached items, and save more time.
Approach(2) probably will cause nasty difficult to spot bugs, because the data come from BLL and placed directly into cache, One can't assume no bugs will happen at the sproc, I am not worry about database runtime errors, runtime errors will show up, but I am worry about invalid data, or miss calculation. Can I proceed with approach (2) with caution? Is there a "best practice" principle which suggest not doing approach(2)?
View 2 Replies
Sep 20, 2010
I've got a single table, with project information and schedule information. To make the data easier to present, I created a tab control with two panels (a detailsview in each). The first tab is for project info, the second tab is for schedule info (again, all fields in the same table). The problem is, if i change info in both tabs, and then hit the update button, only the data from one tab is added to the table. I think this problem is simple to fix, and boils down to the way I have the page organized, but I can't quite figure it out.
I've boiled my code down to the following conceptualized structure:
[code]....
When you click the update button, you return to the listview, but with only the information from your current tab saved. How can I get it to update from both detailsviews?
View 3 Replies
Mar 1, 2010
I'm sure this has been answered many times already, but I still can't seem to find exactly how to search for this issue, so apologies in advance.
Anyway, I have a VB script for entering a row of data into a table by a web user. When this row of data is entered, I wish to take some of the values from the columns of the "primary" table, and have that data automatically create a new row of data in a "secondary" table. I think I'm part of the way there, here is my script:
[code]...
"ProductsByMfr" is the "primary" table - the table that the user adds data into when the button click event is fired.
"DealerPricing" is a "secondary" table that I wish to have some of the data from the newly-entered row in ProductsByMfr copied into. Am I even close here?
View 8 Replies
Aug 13, 2010
Here's my scenario:
I'm using the ASP.Net Membership provider, but I don't want to allow system administrators to DELETE any users. Instead, I simply want to mark them as locked out (aspnet_Membership.IsLockedOut) of the system so they can't log in when an administrator assigns them to a role titled "Inactive". Make sense? Right now my trigger isn't throwing any errors, but it's not working either. Here's my trigger (which is on the aspnet_UsersInRoles table):
[Code]....
View 3 Replies
Sep 18, 2010
I am trying to delete or add rows in a table but since the table is in an update panel,upon deletion the row goes away and then comes back.I have tried using return false but it does not seem to work in IE or FF.
I am using the following code:
$(document).ready(function () {
$(.table).click (function ()}
(this).parent().remove();
[code]...
Basically I need a way to disable the postback.
View 5 Replies
Oct 7, 2010
I have update statement.
UPDATE SPECT SET SRE = CLSS.NEWSID
FROM SPECT
INNER JOIN
student (NOLOCK) ON student.ID = SPECT.ID
INNER JOIN CLSS
ON CLSS.GID = SPECT.GID
ON CLSS.GID = student.GID
WHERE student.PID = '20201'
AND CLSS.PID = '20201'
AND SRE IS NOT NULL
However, student.PID and ClSS.PID need dynamically reach through from table CLSS to get each row of PID.
Here my table CLSS
[code]...
How to finish this one?
View 5 Replies
Jan 20, 2011
I have table a and would like update table a whose values from table b, but not update all rows at table a. Only update record ID in table a match record ID in tableC.
Here is my query
update a
set a.Desc = b.Desc,
a.Value = b.Value
from TableA a, TableB b
where a.name = b.name
and a.ID = b.ID
and a.ID in ( select ID from TableC)
I only have 12 a.ID match TableC, but above query update whole TableA.
How to only update 12 record at TableA from TableB?
View 2 Replies
Mar 1, 2010
I'm trying to update one my my tables from a field in another table.
I have Address fields on both tables and the old table has some addresses I need to copy over (I dont want to copy/paste or type them all in obviously). I basically need to:
[code]...
View 2 Replies
Mar 15, 2011
I have to find the best way to do this using LINQ. I need to summarize an amount in a iTransaction table by
Account (e.g. 12345) and add that amount to an same Account ( e.g12345) if it exists in a iAccount table . Here is the code which syntax checks ok and tested ok up to the .submitChanges statement (i.e. I stopped and didn't allow the submit.
Following is the LINQ code. (1) Is that a good way to do this. OR should I try the INTERCEPT.
(2) How is the best way to insert a new record/row in the iAccounts table if it DOES NOT exist in the iAccount Table.
[Code]....
View 2 Replies
Oct 11, 2010
What are the key differences between these and when should they be used? My initial understanding was that SqlCacheDependency used polling but I've read it doesn't have too for ASP.NET 2.0. I want to know which is most appropriate for caching of linq queries under ASP.NET web server. This will be ASP.NET 3.5.
SqlCacheDependency
http://forums.asp.net/p/1010106/1353521.aspx [code]....
View 1 Replies
Feb 13, 2011
I'm trying to use SqlCacheDependency with List<T>, but searching google etc only comes back with datasets, datatables etc.
So how do i use SqlCacheDependency with the following code:
public List<GetCurrencyCodeOBJ> GetListCurrencyCode()
{
SqlConnection cn = new SqlConnection(dbConn);[code]....
View 1 Replies
Nov 30, 2010
I find the SqlCacheDependency very useful when writing C# ASP.NET applications, and would love to use something similar in my PHP applications. Can anyone suggest something?
SqlCacheDependency caches the page page output forever, until the specified table(s) are modified in the database.
Here's the basic jist of what happens in ASP.NET:
SqlCacheDependency SqlDep = null;
// Check the Cache for the SqlSource key.
// If it isn't there, create it with a dependency [code]...
So does anyone know of any MySql table dependency technique? - much cleaner than time-based caching.
View 1 Replies
Feb 24, 2011
I'm really struggling to get this to work, how can i set up SqlCacheDependency on a List<>
My code is as follows:
[Code]....
All examples i find either relate to datasets etc or adding tables to sql
I'm currently using SQL2008 Express and NET 4.0
View 2 Replies
Mar 29, 2010
Is it correct to implement my caching object like this in my controller :
[code]....
And I Use it like this :
[code]....
View 1 Replies
Feb 25, 2011
We have a wfc layer that wraps the business classes and database access and use a client that lives on the database layer. Amongst our group we are attempting to form standards. Some want to have the client call the web method and pass the page they are requesting and the page size. Pass that to the database and then page in SQL Server use RowNum.Some want to cache the full list of objects in http cache on the service tier and page in memory. They concern here is memory use on the server.
Which would be best for a medium number of users with potentially large number of records to manage (say 30K) Is it better to cache them all in memory and work from there or page at the database as the application scales?
View 1 Replies
Jul 28, 2010
What are the "optimal" parameters for creating an AppFabric cache when you will be storing session state in the cache? MSDN Cache-Related Commands
Powershell command line:
New-Cache [-CacheName] <String> [-Eviction <String>] [-Expirable <String>] [-Force [<SwitchParameter>]] [-NotificationsEnabled <String>] [-Secondaries <Int32>] [-TimeToLive <Int64>]
[code]...
Since I don't want my sessions to be removed unless the session has been abandoned either via code or Session Timeout...For eviction, I would think "None" and for expireable, I would think False.I have tested and calling Session.Abandon does remove the object from the cache. I have also tested to see if by extending my session, the session object in cache is also extended. This does seem to work the "correct" way.
View 1 Replies