Header rows locked or missing ? RRS feed

  • Question

  • Hi all, maybe you can give me a bit of help with this one :

    I am using .NET version 4.0 in C# (but the problem is there since .NET 2.0, our applications have been updated along with .NET versions ). These are multi-user systems.

    We are using strongly typed DataTables and strongly typed DataSets along with SQL server.

    In Some DataSets there are relationships between header and  details and sometimes subdetails and 99.9999% of the time all goes well, except sometimes when I try to update a set of data or simply read a new set based on a key I will receive the detail rows, but not the header rows from SQL. This is not a logic error and to prove it I created a little trap in the programming to re read if the case happens and it works after a bunch of tries.

    Not the full code here but an example of a read in a strongly typed DataSet:

                        reading = true;
                        this.EnforceConstraints = false;
                        syncTime = DataServer.GetServerTime();
                        InvoiceHeaders headers = (InvoiceHeaders)this[0];
                        InvoiceDetails details = (InvoiceDetails)this[1];
                        if (headers.Rows.Count == 0 && details.Count > 0)
                            while (headers.Rows.Count == 0)
                                CNMX.Membership.Security.EventWriter.Writer.Write("The system was forced to re-read invoice while reading invoice number " + invoiceNumber.ToString(), 3000, System.Diagnostics.EventLogEntryType.Warning);
                        this.EnforceConstraints = true;
                        reading = false;

    This works perfectly, as I re enable the constraints only after I am sure that the header row is present.

    Tuesday, April 16, 2013 5:51 PM


  • I like your post but no, at this point any update done the database is done and I am trying to read form an empty DataSet. Also the problem appears in ASP .Net applications where there is no data binding in the strict sense.


    True and wrong. You can bind the dataset but you have to restore it from for instance a sessionstate (that is the one I like). The Dataset is very optimised for that. (You can also use the cache, the viewstate or creating shared classes).

    This because Asp.Net programs have no state themselves. I thought it was off topic but because the optimal use of a dataset in the sessionstate I think it still is. :-)


    Tuesday, April 23, 2013 9:19 AM

All replies