I am new to this tool but after following the tutorial I am unable to get a simple update to save to an Oracle database using the following code:
RTPCRDataContext db = GetDb();
// update the comments for one record
RTPCR_DAT myUpdate = db.RTPCR_DATs.First(d => d.EU_ID == 180326520);
myUpdate.COMMENTS = "Updated comments...";
db.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict);
// get the updated information from the database
RTPCR_DAT myRead = db.RTPCR_DATs.Single(d => d.EU_ID == 180326520);
Response.Write(" updated comment = " + myRead.COMMENTS);
I can make changes directly to the database using Toad and I have tried several different fields and several different records but the changes are not being persisted. I have also tried it in a transaction, with and without the "System.Data.Linq.ConflictMode.FailOnFirstConflict" and have tried setting the Update Check properties on that field as Always, Never and WhenChanged. I'm prepared for this to be a really simple (DUH!) oversight on my part so could someone please point out what I'm missing?
Thank you!
SubmitChanges() Not Persisting
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
Could you please describe the behaviour you are observing more precisely? For example, please specify the following:
- the initial (before submitting the changes) value of the 'myUpdate.COMMENTS' property;
- what is the value of the COMMENTS column of the corresponding row in the database (please check it via some standard tool);
- what is the value of the 'myUpdate.COMMENTS' property you see when re-loading 'myUpdate' after the update;
- whether any triggers are enabled for the 'RTPCR_DAT' table in the database;
- the SQL commands executed against the database (for the details on tracing the generated SQL, please see the corresponding section in our documentation).
- the initial (before submitting the changes) value of the 'myUpdate.COMMENTS' property;
- what is the value of the COMMENTS column of the corresponding row in the database (please check it via some standard tool);
- what is the value of the 'myUpdate.COMMENTS' property you see when re-loading 'myUpdate' after the update;
- whether any triggers are enabled for the 'RTPCR_DAT' table in the database;
- the SQL commands executed against the database (for the details on tracing the generated SQL, please see the corresponding section in our documentation).
SubmitChanges() Not Persisting - resolved
Hi StanislavK,
There was, in fact, a trigger on that table that was hampering the expected functionality. So you nailed it and it was definitely an oversight on my part. I'm currently updating an old desktop app to a more robust web application so what that trigger did is still needed but it can be more efficiently implemented in a different manner. In the mean time I had the opportunity to get familiar with your dbMonitor and I really like it too. Thank you for getting back to me and pointing me in the right direction and thanks for all the work you and the team put into this product! It will be a regular part of our web solutions framework.
s1buick
There was, in fact, a trigger on that table that was hampering the expected functionality. So you nailed it and it was definitely an oversight on my part. I'm currently updating an old desktop app to a more robust web application so what that trigger did is still needed but it can be more efficiently implemented in a different manner. In the mean time I had the opportunity to get familiar with your dbMonitor and I really like it too. Thank you for getting back to me and pointing me in the right direction and thanks for all the work you and the team put into this product! It will be a regular part of our web solutions framework.
s1buick
Everything is working well with several other tables I'm working with but, now that I've returned to the RTPCR_DAT table (the one I was initially having a problem with) I still can't get it to update even after I've removed the trigger and all constraints. Here are a couple of examples from the DBMonitor logs that illustrate the strange behavior. First, the code and corresponding log from one that works with the FC_RTPCR_CNDAT table:
The only thing I'm noticing so far is that there isn't an UPDATE statement being prepared and executed by the ORM following the 'Begin local transaction Complete' in the second example. That would explain why the update doesn't occur but I'd sure like to figure out why the update statement wasn't created.
Any ideas? Could it be a problem with the model that was generated with the trigger in place and I just need to regenerate the whole RTPCRDataContext.lqml again?
Thanks
Code: Select all
protected void gridCNDAT_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
{
RTPCRDataContext context = Utilities.GetContext();
RTPCR_CNDAT myComment = context.RTPCR_CNDATs.First(d => d.EU_ID == Convert.ToInt32(e.NewValues["EU_ID"].ToString()));
myComment.LAB_COMMENTS = e.NewValues["LAB_COMMENTS"].ToString();
context.SubmitChanges();
//Cancel automatic update
e.Cancel = true;
//back to the browse mode
gridCNDAT.CancelEdit();
// Re-load the grid to show the changes.
LoadGrid();
}
2/14/2012 2:54:28 PM 0.000 Creating object Complete
2/14/2012 2:54:28 PM 0.000 Open connection: "User Id=..." Complete
2/14/2012 2:54:28 PM 0.000 Taking connection from connection pool: "User Id=..." Complete
2/14/2012 2:54:28 PM 0.000 Connection is taken from pool. Pool has 2 connection(s). Complete
2/14/2012 2:54:28 PM 0.000 Creating object Complete
2/14/2012 2:54:28 PM 0.000 Prepare: SELECT t1.EU_ID, t1.SCORE, t1.P1, t1.P2, t1.P3, t1.P4, t1.FILENAME, t1.UPLOADDATE, t1.LAB_COMMENTS
FROM FC_RTPCR_CNDAT t1
WHERE (t1.EU_ID = :p0) AND (ROWNUM d.EU_ID == Convert.ToInt32(e.NewValues["EU_ID"].ToString()));
myComment.COMMENTS = e.NewValues["COMMENTS"].ToString();
context.SubmitChanges();
//Cancel automatic update
e.Cancel = true;
//back to the browse mode
gridRTPCRDAT.CancelEdit();
// Re-load the grid to show the changes.
LoadGrid();
}
2/14/2012 2:59:39 PM 0.000 Creating object Complete
2/14/2012 2:59:39 PM 0.000 Open connection: "User Id=..." Complete
2/14/2012 2:59:39 PM 0.000 Taking connection from connection pool: "User Id=..." Complete
2/14/2012 2:59:39 PM 0.000 Connection is taken from pool. Pool has 2 connection(s). Complete
2/14/2012 2:59:39 PM 0.000 Creating object Complete
2/14/2012 2:59:39 PM 0.000 Prepare: SELECT t1.EU_ID, t1.PLATE_ID, t1.RUN_DATETIME, t1.ASSAY_TYPE, t1.SAMPLE_GROUP, t1.DATA_TYP, t1.DET_NAME_TGT, t1.CTRL_FLAG, t1.LIMS, t1.TEST_STATUS, t1.TGT_CT, t1.REF_CT, t1.CT_MEDIAN_TGT, t1.CT_MEDIAN_REF, t1.DELTA_CT_TEST, t1.DELTA_CT_CTRL, t1.DELTA_DELTA_CT, t1.COMMENTS
FROM FC_RTPCR_DAT t1
WHERE (t1.EU_ID = :p0) AND (ROWNUM <= 1) Complete
2/14/2012 2:59:39 PM 0.000 Execute: SELECT t1.EU_ID, t1.PLATE_ID, t1.RUN_DATETIME, t1.ASSAY_TYPE, t1.SAMPLE_GROUP, t1.DATA_TYP, t1.DET_NAME_TGT, t1.CTRL_FLAG, t1.LIMS, t1.TEST_STATUS, t1.TGT_CT, t1.REF_CT, t1.CT_MEDIAN_TGT, t1.CT_MEDIAN_REF, t1.DELTA_CT_TEST, t1.DELTA_CT_CTRL, t1.DELTA_DELTA_CT, t1.COMMENTS
FROM FC_RTPCR_DAT t1
WHERE (t1.EU_ID = :p0) AND (ROWNUM <= 1) Complete
2/14/2012 2:59:39 PM 0.015 Rollback Complete
2/14/2012 2:59:39 PM 0.000 Close connection Complete
2/14/2012 2:59:39 PM 0.000 Connection is returned to pool. Pool has 2 connection(s). Complete
2/14/2012 2:59:39 PM 0.016 Open connection: "User Id=..." Complete
2/14/2012 2:59:39 PM 0.016 Taking connection from connection pool: "User Id=..." Complete
2/14/2012 2:59:39 PM 0.000 Connection is taken from pool. Pool has 2 connection(s). Complete
2/14/2012 2:59:39 PM 0.000 Begin local transaction Complete
2/14/2012 2:59:39 PM 0.000 Creating object Complete
2/14/2012 2:59:39 PM 0.000 Commit Complete
2/14/2012 2:59:39 PM 0.000 Rollback Complete
2/14/2012 2:59:39 PM 0.000 Close connection Complete
2/14/2012 2:59:39 PM 0.000 Connection is returned to pool. Pool has 2 connection(s). Complete
The only thing I'm noticing so far is that there isn't an UPDATE statement being prepared and executed by the ORM following the 'Begin local transaction Complete' in the second example. That would explain why the update doesn't occur but I'd sure like to figure out why the update statement wasn't created.
Any ideas? Could it be a problem with the model that was generated with the trigger in place and I just need to regenerate the whole RTPCRDataContext.lqml again?
Thanks
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
Please check the initial value of myComment.COMMENTS and the one set by 'e.NewValues["COMMENTS"].ToString()'. A probable reason for this situation is that these values are identical; in this case, the LinqConnect runtime will register no changes in this entity, thus no update command will be executed.
If these values are different, but still no update command is executed, please try simplifying the scenario: e.g., shorten it to just fetching the entity, modifying its COMMENTS property and submitting the changes:
Please tell us if the issue can be reproduced in this case.
If these values are different, but still no update command is executed, please try simplifying the scenario: e.g., shorten it to just fetching the entity, modifying its COMMENTS property and submitting the changes:
Code: Select all
RTPCRDataContext context = Utilities.GetContext();
RTPCR_DAT myComment = context.RTPCR_DATs.First(
d => d.EU_ID == {set the entity key here}
);
myComment.COMMENTS = {set the string constant here};
context.SubmitChanges();