We are working with a legacy MSSQL database and VB.NET. The following was determined by looking at the database directly after the page cycle finished.

psuedo code:

LoadOrCreate(ByVal val As Integer) As Obj
    Dim objID As Integer
    Using transaction = Session.Demand().OpenTransaction(TransactionOpenMode.New)
        Dim newObj As Obj = Obj.Create()
        With newObj
            .Prop1 = val
            .Prop2 = GetCalculatedPropValue()
        End With
        objID = newObj.ID
        If Not newObj.HasDuplicate()
            transaction.Complete()
        Else
            objID = newObj.GetDuplicateID()
        End If
    End Using
    Return Load(objID)
End Function

This gets called one or more times. It always works the first time it is called. It also works every time that is not the last time it is called. The Prop# properties are not getting saved to the database the last time the above is called when it has been called at least once before. The object is always created if it was supposed to be. E.g.

Dim obj1 As Obj = Obj.LoadOrCreate(1) ' works '

AND

Dim obj1 As Obj = Obj.LoadOrCreate(1) ' works '
Dim obj2 As Obj = Obj.LoadOrCreate(2) ' fails '

AND

Dim obj1 As Obj = Obj.LoadOrCreate(1) ' works '
Dim obj2 As Obj = Obj.LoadOrCreate(2) ' works '
Dim obj3 As Obj = Obj.LoadOrCreate(3) ' fails '

At the end of the button OnClick subroutine, the user is sent to a success page using Response.Redirect(). My hunch is that the Prop1 value is not getting saved to the database because the transaction opened by DataObject at the beginning of the page request is never successfully closed/completed, and the values are getting written in other cases because there are a number of database read and write operations that would trigger database visits by DataObjects in other circumstances. Does anyone know how to force DataObjects to make a database visit (i.e. write pending changes) or have alternative ideas as to why the Prop values are not getting saved in this one case?

asked Oct 05 '11 at 13:08

GigMastersTech's gravatar image

GigMastersTech
27111115

edited Oct 05 '11 at 17:17

Hello GigMastersTech,

The issue seems to be a bit weird. Are there any chance of a sample that reproduces the problem? It would help us a lot.

Thanks in advance.

(Oct 06 '11 at 06:01) Dmitri Maximov Dmitri%20Maximov's gravatar image
1

Sure thing. Reproducing this issue outside of the whole system is taking a bit longer than I thought, but I think it is still a good exercise because I might encounter a solution or a root cause other than my suspect while doing this.

(Oct 07 '11 at 09:24) GigMastersTech GigMastersTech's gravatar image

Thanks for the understanding. I wish you good luck and let the force be with you =)

(Oct 07 '11 at 09:29) Dmitri Maximov Dmitri%20Maximov's gravatar image

I completely understand that not having a way to replicate a problem essentially means it is irreparable. Anyway, I have managed to replicate a failure to read from the database, but cannot yet replicate the failure to write. The example is here: http://www.mediafire.com/file/69mlyk6edfnnp0j/DO_test.zip Contents: {Global.asax, Web.Config, TestObjects.vb, zTestPage.aspx, zTestPage.aspx.vb}

Super is required. Enter 1 parent -> works. Enter multiple parents -> only first works. Everything is getting written to the database, including each parent's UPDATE; I'm working on getting this to break.

(Oct 07 '11 at 12:40) GigMastersTech GigMastersTech's gravatar image

Thanks, I will check this shortly. Likely, right in the beginning of the next week.

(Oct 07 '11 at 13:20) Dmitri Maximov Dmitri%20Maximov's gravatar image

Thank you very much. I forgot to include the test case database SQL before but have just updated the zip by adding TestCaseDB.sql to the above zip, same url to get at it.

(Oct 07 '11 at 15:40) GigMastersTech GigMastersTech's gravatar image

Hello GigMastersTech,

I tried building the sample and but unfortunately, was stuck. Could you help me with that?

My e-mail is dmitri.maximov at dataobjects.net; skype: dmitri.maximov

Thanks in advance.

(Oct 14 '11 at 10:09) Dmitri Maximov Dmitri%20Maximov's gravatar image

Apologies. I was unaware of the in-house DomainBuilder. I have an updated the example with the extra function in Global.asax and included files for a Visual Studio 2010 solution containing a class library project and a web site project: http://www.mediafire.com/file/61qbc3tb33aacco/DOtest.zip

(Oct 21 '11 at 18:58) GigMastersTech GigMastersTech's gravatar image

Thanks for the updated solution. I made some changes to it and sent it back with some comments. Check the e-mail, please.

(Oct 23 '11 at 08:50) Dmitri Maximov Dmitri%20Maximov's gravatar image
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

Subscription:

Once you sign in you will be able to subscribe for any updates here

Tags:

×23
×7
×5

Asked: Oct 05 '11 at 13:08

Seen: 3,582 times

Last updated: Oct 23 '11 at 08:50

powered by OSQA