Click here to Skip to main content
15,887,596 members
Home / Discussions / Database
   

Database

 
AnswerRe: Should I use SQL Server as backend for huge charting application? Pin
Mycroft Holmes25-Jul-08 23:01
professionalMycroft Holmes25-Jul-08 23:01 
GeneralRe: Should I use SQL Server as backend for huge charting application? Pin
mahabir26-Jul-08 17:50
mahabir26-Jul-08 17:50 
GeneralRe: Should I use SQL Server as backend for huge charting application? Pin
Mycroft Holmes26-Jul-08 21:28
professionalMycroft Holmes26-Jul-08 21:28 
QuestionADO Excel problem Pin
followait25-Jul-08 16:36
followait25-Jul-08 16:36 
AnswerRe: ADO Excel problem Pin
Mycroft Holmes25-Jul-08 23:05
professionalMycroft Holmes25-Jul-08 23:05 
GeneralRe: ADO Excel problem Pin
followait26-Jul-08 6:07
followait26-Jul-08 6:07 
GeneralRe: ADO Excel problem Pin
Mycroft Holmes26-Jul-08 14:17
professionalMycroft Holmes26-Jul-08 14:17 
QuestionLINQ to SQL and TransactionScope == DTC Pin
Mark J. Miller25-Jul-08 12:33
Mark J. Miller25-Jul-08 12:33 
The client I'm working for is using LINQ to SQL behind a BLL of sorts. So each CRUD operation gets its own context. Here's an example of the Save method:

<br />
        public static Step Save(Step step)<br />
        {<br />
			using ( KRATDataContext context = new KRATDataContext( Helpers.EnvironmentState.CurrentConnectionString ) )<br />
			{<br />
				Step oldStep = step.StepID > 0 ? context.Steps.Single( p => p.StepID == step.StepID ) : null;<br />
<br />
				if ( oldStep == null )<br />
				{<br />
					context.Steps.InsertOnSubmit( step );<br />
				}<br />
				else<br />
				{<br />
					oldStep.Description = step.Description;<br />
					oldStep.PotentialHazard = step.PotentialHazard;<br />
					oldStep.ActionsToReduceRisk = step.ActionsToReduceRisk;<br />
					oldStep.InitialRiskCellID = step.InitialRiskCellID;<br />
					oldStep.PostRiskCellID = step.PostRiskCellID;<br />
					oldStep.DateCreated = step.DateCreated;<br />
					oldStep.RiskAnalysisID = step.RiskAnalysisID;<br />
					oldStep.DisplayIndex = step.DisplayIndex;<br />
				}<br />
				context.SubmitChanges();<br />
<br />
				return step;<br />
			}<br />
        }<br />
<br />


I have implemented functionality which allows a user to change the display order of a "Step" record by clicking an up/down arrow which essentially swaps the value of DisplayIndex for two separate records. Like this:
<br />
protected void Swap(int stepId1, stepId2)<br />
{<br />
  // get the actual records<br />
  Step step1 = Step.GetOne(stepId1);<br />
  Step step2 = Step.GetOne(stepId2);<br />
<br />
  // do the real swap (left out logic on purpose to focus on issue)<br />
  Swap(step1, step2);<br />
<br />
  using( System.Transactions.TransactionScope txCtx = new System.Transactions.TransactionScope()){<br />
    Step.Save(step1);<br />
    Step.Save(step2);<br />
<br />
    txCtx.Complete();<br />
  }<br />
}<br />


The important fact being demonstrated here is that each save operation has its own DataContext. So when the 2nd call to Save() is made I get an exception because I have explicitly turned off DTC (ie. I don't allow remote DTC operations). But these two records are in the same table.

So here's what I'm looking for:

1) Can someone else confirm this for me, but duplicating the error I get.
2) Is there a way around this, other than using the same DataContext object?
3) I'll need to double check, but this doesn't happen to me when I use the EnterpriseLibrary connection objects with TransactionScope. So is this a bug? Or at least something that should be changed so it works the way EnterpriseLibrary does?

#2 is important because while fixing this issue for the specific case above (both objects are based on the same database table) I have other cases where I'll have to create specialized methods in my data access layer which allow me to use the same data context so I can wrap operations on different tables with the same DataContext.

As always, I appreciate the help.

[Edit]
Here's the exception detail:

System.Transactions.TransactionManagerCommunicationException was unhandled by user code
Message="Communication with the underlying transaction manager has failed."
Source="System.Transactions"

InnerException: System.Runtime.InteropServices.COMException
Message="Error HRESULT E_FAIL has been returned from a call to a COM component."
Source="System.Transactions"

[/Edit]

Code responsibly: OWASP.org
Mark's blog: developMENTALmadness.blogspot.com

AnswerRe: LINQ to SQL and TransactionScope == DTC Pin
Mark J. Miller28-Jul-08 10:18
Mark J. Miller28-Jul-08 10:18 
QuestionDatabase column Pin
Verghese25-Jul-08 9:10
Verghese25-Jul-08 9:10 
AnswerRe: Database column Pin
Blue_Boy25-Jul-08 11:59
Blue_Boy25-Jul-08 11:59 
QuestionCrystal Report Title @ Run Time Pin
Verghese25-Jul-08 5:33
Verghese25-Jul-08 5:33 
AnswerRe: Crystal Report Title @ Run Time Pin
SomeGuyThatIsMe25-Jul-08 5:52
SomeGuyThatIsMe25-Jul-08 5:52 
AnswerRe: Crystal Report Title Pin
David Mujica25-Jul-08 6:32
David Mujica25-Jul-08 6:32 
GeneralRe: Crystal Report Title Pin
Verghese25-Jul-08 9:17
Verghese25-Jul-08 9:17 
AnswerRe: Crystal Report Title @ Run Time Pin
Wendelius25-Jul-08 10:17
mentorWendelius25-Jul-08 10:17 
QuestionDynamic Database Creation ?? Pin
C. L. Phillip25-Jul-08 4:13
C. L. Phillip25-Jul-08 4:13 
AnswerRe: Dynamic Database Creation ?? Pin
TheFM23425-Jul-08 4:42
TheFM23425-Jul-08 4:42 
GeneralRe: Dynamic Database Creation ?? Pin
C. L. Phillip25-Jul-08 4:49
C. L. Phillip25-Jul-08 4:49 
AnswerRe: Dynamic Database Creation ?? Pin
TheFM23425-Jul-08 5:14
TheFM23425-Jul-08 5:14 
GeneralRe: Dynamic Database Creation ?? Pin
C. L. Phillip25-Jul-08 5:23
C. L. Phillip25-Jul-08 5:23 
GeneralRe: Dynamic Database Creation ?? Pin
BhadeliaImran26-Jul-08 1:53
BhadeliaImran26-Jul-08 1:53 
AnswerRe: Dynamic Database Creation ?? Pin
Wendelius25-Jul-08 9:53
mentorWendelius25-Jul-08 9:53 
AnswerRe: Dynamic Database Creation ?? Pin
Mycroft Holmes25-Jul-08 22:39
professionalMycroft Holmes25-Jul-08 22:39 
GeneralRe: Dynamic Database Creation ?? Pin
C. L. Phillip27-Jul-08 5:41
C. L. Phillip27-Jul-08 5:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.