C# - Cache A Dataset When Database Table Being Update?
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
Similar Messages:
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
Feb 25, 2010
I select few columns from table A in dataset. Example "EMP_ID","Name","Address","Phone_Number". I want to save data in this dataset into some other table B.
I want to save data from dataset into table B. But i want to have following functionality
1. Before saving a record from dataset to table B if that record if previously present in table B, if yes then check if any value are different, if yes then update that record with the record from dataset, if all the values are same then leave the records as is.
2. If the record is not present in table B then insert it new records in table B from dataset.
Is there any efficient way to implement in .NET C#.
View 1 Replies
Feb 14, 2011
How to update database with dataset
View 4 Replies
Mar 14, 2010
1. As per my knowledge we use dataadapters/dataset when we want to deal with the huge amount of column/data. Is there anyway that if I want to update one or two columns in a table without using dataadapter/dataset?
2. There is a way that without clicking a button we can get the data using objectdatasource, I mean to say that there is no vb.net data in the code behind then how to debug if there is not data in vb.net in code behind.
View 6 Replies
Feb 22, 2011
I have an asp.net application using visual studio express 2008. On one of my pages I created a dataset from one of my database tables. I am able to delete rows and add rows to the new dataset table. I then have a button and on the click event I use the commandbuilder to update the database table. The database table updates with new rows but the deleted rows are not carried out and I can not figure out why desite spending several hours on google to resolve this issue?
Here is some of my code:
Protected Sub Button_updateDatabase_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button_updateDatabase.Click
Try
'I have created a session variable for my data adapter
Dim commandbuilder As SqlCommandBuilder = New SqlCommandBuilder(Session("Adapter"))
Session("Adapter").UpdateCommand = commandbuilder.GetUpdateCommand
Session("Adapter").DeleteCommand = commandbuilder.GetDeleteCommand
'I created a session variable for my dataset
'This update command updates new rows to my database table but not deleted rows
Session("Adapter").Update(Session("CalendarDataset"), "Name")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
View 4 Replies
Jun 8, 2010
My dataset table data is from multiple tables (showing on a gridview),How to update the database tables using batch udpate on clicking submit, if the data is from a signle table, no problem, but I am not sure how to handle if the datais from mulitiple tables? If I have related tables, do I need put them in differet tables in the dataset?
View 6 Replies
Apr 1, 2010
I'm fairly new to asp.net and I'm trying get my arms around the data entry and update. I have created a nice data entry formusing a stored procedure. It works well but for a test database, it's pretty much overkill, but worthwell in learning how. I'm going through the ADO.NET quick start tutorial and I've ran across a couple of questions that I've not be able to answer. In my website,I'm wanting to edit the database by creating a separate form that is filled with the existing database information for that particular id. My main question is how to I take the information from the dataset and get it into my form. The code below is not fillingmy form. Not sure what I should be using here:
[Code]....
View 3 Replies
Jan 23, 2010
I want to reformat one column in database. So that I've used strong typed dataset by drag and drop in VS 2008. When I've already updated all data in dataset, I call method update() of table adapter to perform update my modified data of dataset into database. But it doesn't work.
Below is my code
[Code]....
The RemoveWhiteSpace(string input) is my function to remove special characters from dataset.
View 2 Replies
Apr 1, 2010
Im Inserting data into database table with the help of datasets but its not inserting to table and even its not showing errors.
this is my code....
[code]....
View 3 Replies
Jan 14, 2010
Im building a image gallery which reads file from disk, create thumbnails on the fly and present them to the user. This works good, except the processing takes a bit time.
I then decided to cache the processed images using the ASP .NET Application Cache. When a image is processed I add the byte[] stream to the cache. As far as I know this is beeing saved into the system memory. And this is working perfect, the loading of the page is much faster.
My question is if there are thousands of images which gets cached in the Application Cache, will that affect the server performance in any way?
View 3 Replies
Jan 22, 2010
MSVS 2005 asp.net 2.0 ajax enabled site..
I havent used asp.net 2.0 rsskit..didnt know there wasone..
anyways.. I have this RSS code that pulls RSS contents from a stored proc into a dataset (ds)..
Question : How can I cache the Dataset variable (ie ds) so that if I have 100 hits in 5 min I dont get 100 pulls on the stored proc. [NOTE: I assume its best to cache the dataset]
my code for RSS from the dataset (note has a few custom function etc..)
[Code]....
View 1 Replies
Sep 11, 2010
I am creating a search results page in C# in an ASP.NET 1.1 page. In my data layer I have a DataSet that stores the result of a plain old ADO.NET stored procedure call. The DataSet has two DataTables and I'm using a DataVIew to filter and sort the columns.
I only want to fill the dataset once, and then work on the DataTables and derived DataView until the page is unloaded. How best should I cache the DataSet in my DAL so that it is filled only PageLoad? Do i put it in a Cache object, a static member variable, a property...
View 4 Replies
Sep 19, 2010
I have created normalised data tables to hold look up information (such as venues, players, teams etc) and want to dynamically update the 'matches' data table (my transactions) using webpages instead of running SQL queries.
What I want to do is select a name from a drop down list and then post the relevant ID associated with that name to my 'matches' table. At the moment I can only link to the value in the drop down list, i.e. the name which is incompatible with the validation which expects a primary key integer.
I'm sure this problem is a fairly common one but I haven't found the right answer on any of the tutorials or blogs, all of them assume that the data is de-normalised or describe things in more technical ways than I can yet understand. If anyone can point me to a 'how to article' or tell me what I am doing wrong, I would be grateful.
View 7 Replies
Oct 2, 2012
How can i update, delete 2 table in gridview?
I have created 2 table in access
1. Recipient (Userid, RecipientId, RecipientName, Company, DeliveryAddressId)
2. MailingAddress (Id, BuildingInfo, StreetInfo, City, Province)
I connected this gridview with sqldatasource
"SELECT Recipient.UserId, Recipient.RecipientId, Recipient.RecipientName, Recipient.Company, MailingAddress.BuildingInfo, MailingAddress.StreetInfo, MailingAddress.City, MailingAddress.Province FROM (Recipient INNER JOIN MailingAddress ON Recipient.DeliveryAddressId = MailingAddress.Id)"
The gridview it can select from 2 table, (RecipientId, RecipientName, Company, BuildingInfo, StreetInfo, City, Province) but cannot update 2 table.
View 1 Replies
Nov 29, 2010
I am writing a web page that returns a small volume of data from a database table. The database is polled every 1 second and the data will be the same for every user. As every user is accessing the same data, there is no need for each user to poll the database and use up db resource.
Therefore, I think I should be using application caching to store the data in a dataset. However, I am slightly stumped as to how to do this.... because how can i ensure that the dataset is kept up to date.
The only way I can think to do this is to have a master user/session (i.e. the first session in the application) that keeps the cache object updated every second, then other users can use that cache object. If the first session ends, then the next requestor of the cache will pick up responsibility for keeping the dataset up to date.
View 4 Replies
Dec 16, 2010
Am trying to build a page that will display one record at a time. That is the user searches a records table and the page displays the record. Than when the user us done making any changes and clicks save, i want the page to update the records table. So far, i have the page displaying the search results, but the save functionality is not working. Actually after changing an entry and the save button is clicked, the records change are currently reverting back to the old data that they want to change it from. How do i go about updating the records in the database? Here is the code that I have been able to come up with so far.
[Code]....
View 3 Replies
Mar 25, 2011
I'm storing a dataset in an ASP.Net WebApplication-Cache. Every user in this intranet-app uses the same instance. On insert/update/delete-actions the database will be updated and the dataset is modified accordingly.
But rarely I get an exception that indicates that I've missed something. I assume that it must have something to do with thread safety.
Collection was modified; enumeration operation might not execute
In lines where i access a DataTable in the Dataset, for example:
Dim view As New DataView(dsERP.ERP_Charge, filter, sort, _
Data.DataViewRowState.CurrentRows)
It was apparently changed by another thread while the view enumerates the datatable.
What is the best way to make this thread safe?
Edit: as you've mentioned i need to lock the objects on add/edit/delete operations. MSDN* says that a DataSet is thread-safe for multiple users. What does this mean, are the DataTables in the Dataset also thread-safe? And how to lock a single datatable on write-operations and not the whole dataset?
*ADO.NET - Multithreaded Programming ADO.NET is optimized for performance, throughput, and scalability. As a result, the ADO.NET objects do not lock resources and must only be used on a single thread. The one exception is the DataSet, which is thread-safe for multiple readers. However, you need lock the DataSet during writes.
This is the property that returns the dataset:
Public ReadOnly Property dsERP() As ERPModel.dsERP
Get
If Cache("DS_ERP") Is Nothing Then
Cache("DS_ERP") = New ERPModel.dsERP
FillDataSet()
End If
Return DirectCast(Cache("DS_ERP"), ERPModel.dsERP)
End Get
End Property
i've modified the insert/update and delete operations in the following way(dsRma is a dataset):
Dim success As Boolean
SyncLock dsRMA.RMA
success = insert()
End SyncLock
First, does it work now if another thread tries to enumerate the RMA-Table? Second, is it sufficient to lock the datarow that gets updated instead of locking the whole datatable(see below)?
Dim thisRMA As ERPModel.dsRMA.RMARow = dsRMA.RMA.FindByIdRMA(Me.IdRma)
Dim success As Boolean
SyncLock thisRMA
success = update(thisRMA)
End SyncLock
View 1 Replies
Apr 6, 2010
I need to browse excel file and update the neccessary tables based on some ID. It is basically updating employees in bulk.
View 7 Replies
Oct 17, 2012
I am creating a dynamic database table, inserting some records in dynamic table and generating update command dynamically. (This part is running ok)
Code:
// Create Table
public void createtable()
{
string sql = "CREATE TABLE " + txtTableName.Text.Trim() + "(" + "InfoCode nvarchar(MAX) NULL, UserName nvarchar(MAX) NULL, Mobile nvarchar(MAX) NULL, Email nvarchar(MAX) NULL";
[Code] ....
And in another page i am displaying the list of all the dynamic database tables. Here user selects table from gridview and the data is displayed to him in dynamically generated HTML Table with Dynamic textboxes. (This part is also running ok)
Code:
// Display data
protected void getTableInfo()
{
int RowNo = 0;
string NotCmd = "Select * From NTL Where InfoCode = @InfoCode";
[Code] ....
Now the problem is how to update the record in database through this dynamically generated html table and texboxes. When I run my dynamically generated update command, all the dynamic controls is lost in postback.
View 1 Replies
Aug 20, 2010
I have table A in database A , in table A i have trigger to insert record to database B table A, each update and insert of database A -table A, triiger fire and insert record in database B table A, when i try to update some times asp.net application gives error
"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."
and then error log says System.Data.SqlClient.SqlException: Database 'database B is being recovered. Waiting until recovery is finished.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)[code]....
View 1 Replies
Dec 21, 2010
I have a detailsview, template as follows:
[Code]....
Codebehind: creating dataset, getting data from sql with adaptor and filling into dataset object, then setting detailsview's datasource.
I add 2 button to above template to able to edit data at asp page, and added event handlers:buttons:
[Code]....
My question is, what to do inside the detailsview update event function to able to edit and update data. My method can be wrong too.
View 7 Replies
Jun 29, 2010
I'm working on a new project where I have the luxury of working from a Model to Database approach using Entity Framework 4.
The project I'm working on is taking an agile approach where different phases will be rolled out over time.
Will the Model First approach work in my case? I noticed when you "Generate Database from Model" it recreates the entire schema from scratch which will obviously wipe all the data that is in the db. I was hoping for a more "Update Database from Model" approach where the db would just be altered to reflect the changes rather than recreated
View 1 Replies
Jun 18, 2010
how to copy from one table to another table in dataset using c#
View 2 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