RE: [SQLDownUnder] .net TransactionScope and Deferred Constraints


    [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
    • From: Adrian Martin
    • Subject: RE: [SQLDownUnder] .net TransactionScope and Deferred Constraints
    • Date: Mon, 04 Sep 2006 00:36:03 -0700

    An approach I've taken is to set Outlook to send items after a specified delay, that helps me take the time to cancel sending if I suddenly realise I didn't need to send that.

    Use Rules and Alerts to make a new one for outgoing messages...

     

    Adrian Martin

    IT Systems Coordinator

    Workways Association Inc

     


    From: SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx [mailto:SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of sql@xxxxxxxxxxx
    Sent: Monday, 4 September 2006 4:43 PM
    To: SQLDownUnder@xxxxxxxxxxxxxxxxxxxxxx
    Subject: RE: [SQLDownUnder] .net TransactionScope and Deferred Constraints

     

    My mistake, code error…

     

    Please ignore my email.

     

    That always happens 5 seconds after you send it!

     

    cheers

     


    From: SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx [mailto:SQLDownUnderList@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of sql@xxxxxxxxxxx
    Sent: Monday, 4 September 2006 4:18 PM
    To: SQLDownUnder@xxxxxxxxxxxxxxxxxxxxxx
    Subject: [SQLDownUnder] .net TransactionScope and Deferred Constraints

     

    Hello,

     

    I am wanting to create surveys with varying amount of questions by inserting into two relations (this is

    a simplified version)

     

    Survey (SurveyID INT, SurveyName VARCHAR)

    SurveyQuestions (QuestionID INT, SurveyID INT, QuestionText VAHRCHAR)

     

    I am trying to achieve this by using TransactionScope. My code is looking something like this (c#):

     

    Using (TransactionScope scope = new TransactionScope)

    {

                Using (SqlCommand insertSurvey ….)

                {

                            …..

                            insertSurvey.ExecuteNonQuery;

    }

     

                Using (SqlCommand insertQuestion ….)

                {

                            ….

    Foreach (SurveyQuestion q in questions)

                            {

    ….

    insertSurveyQuestion.ExecuteNonQuery; ***

                            }                      

                }

                scope.Commit();

    }

     

    My problem is that when the code gets to *** I am violating foreign key constraints.

     

    How can I set the transaction to defer the checking of the constrains either in my

    ADO.net code or in my T-SQL

     

    kind regards,


    Jonathon Kresner

    to unsubscribe to this list, please send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by http://www.readify.net to unsubscribe to this list, please send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by http://www.readify.net to unsubscribe to this list, please send a message back to the list with 'unsubscribe' as the subject. Powered by mailenable.com - List managed by http://www.readify.net



    (Click here for more information on the sqldownunder mailling list)