Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataTable.GetChanges() Crashes...
Message
From
03/02/2007 13:03:48
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01189575
Message ID:
01192122
Views:
18
Ben,

OK, that .Clone() override looks cool and it's a good way to handle the problem.

Now, the other issue with the HasChanges() ... are you doing an .AcceptChanges() anywhere before you check for HasChanges()? That's the only thing that I can think of that would mark any changes back to their Original state.

~~Bonnie



>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
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform