jeudi 2 avril 2015

Update database row after closing Link to SQL


Vote count:

0




I have code where I get rows from a database, extract information which is added to different tables, and update the original row with links to the new primary keys. My problem is that after getting the rows I need to process, I close the connection. I do this because I have quite a bit of processing before resubmitting, and I need to add rows to other tables and get their auto-generated primary keys. Unfortunately, while all of the other data is being added correctly, my original rows are not updating.


First I get the rows I will be working with:



List<Procedure> result = new List<Procedure>();
using (dbContext db = new dbContext(SqlAccess.ConnectionString))
{
var search =
from Proc in db.GetTable<Procedure>()
where Proc.ProcedureID == Guid.Empty
select Proc;
result = search.ToList<Procedure>();
}


I then add rows to different tables, update the Procedure row, and try to check in:



using (dbContext db = new dbContext(SqlAccess.ConnectionString))
{
db.Findings.InsertAllOnSubmit(cadFindings);
db.SubmitChanges();
}


I'm sure I need to add something to my check-in code to say that I want to also check in my updates from the Procedure table, but I haven't been able to find what it is. Any assistance would be greatly appreciated.



asked 56 secs ago

Tim

477






Update database row after closing Link to SQL

Aucun commentaire:

Enregistrer un commentaire