Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataTable.GetChanges() Crashes...
Message
 
À
03/02/2007 12:09:50
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01189575
Message ID:
01192118
Vues:
29
Bonnie,

No you aren't being dense, it's just that what we use it for it a little complicated and intertwined. The DataTables themselves that we derived are not useable independently, they must be used with an accompanying derived DataTableCollection which in turn uses a derived DataSet...etc. In short it's a complete SQLWrapper Class we designed. The DataTable when it is created internally within the main class needs some additional parameters in order to properly link itself within the class. I been spending some time fiddling and I think I might have figured a fix at least for the GetChanges(). Inside my derived DataTable I overrode the Clone() method and added the following code:
        Public Overrides Function Clone() As System.Data.DataTable
            '************************************************************************
            ' Procedure/Function: Clone()
            ' Author: Ben Santiago
            ' Created On: 2/3/2007
            ' Description:
            '       This method was overridden because it is needed for the 
            '       GetChanges() method, avoiding the need for a Parameterless 
            '       Constructor.
            '************************************************************************

            '***************************************
            ' Initialize Variables
            '***************************************
            Dim objClonedTable As ClassLibrary.SQLDBWrapper.ClassDataTable = Activator.CreateInstance(Me.GetType(), New Object() {Me.TableName, Me.Parent, Me._ReadOnly})

            '***************************************
            ' Manually ReCreate Each Field
            '***************************************
            For Each objColumn As DataColumn In Me.Columns
                objClonedTable.Columns.Add(objColumn.ColumnName, objColumn.DataType)
            Next

            '***************************************
            ' Return Cloned Object
            '***************************************
            Return objClonedTable
        End Function
This simply calls the CreateInstance which in turn runs the appropriate Contructor based on the parameters. Then I go ahead and manually copy/recreate each Table Fieldname in the cloned object. and return that object for the GetChanges() to then populate. It appears to work perfectly.

As for the HasChanges(), like I mentioned in a previous post, I did try your EditEdit() code but it did not work. None of the rows reported themselves as being in the "Proposed" state, therefore the IF statement never ran because all the rows were claiming to be current originals. Not sure why though, since there were changes made.

>Ben,
>
>We use custom DataSets too, but we have all the constructors ... maybe I'm being dense, but I don't see why you would have a DataTable class defined with parameters. How are you defining your DataSets? Are you using Typed DataSets?
>
>In regards to the second issue of the .HasChanges() not being true .. that one has to do with the need for calling the .EndEdit() on a Proposed change like I mentioned in my previous post.
>
>~~Bonnie
________________________
Ben Santiago, MCP & A+
Programmer Analyst (SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS)
Eastern Suffolk BOCES - Student Data Services


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-Rich Cook
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform