Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataRelation Prevent my DataSet Updates!!
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00758171
Message ID:
00759938
Vues:
20
That sounds like a good place to start. I would trace through the code and look at the state of the DataSet before trying to update.

>Cathi,
>
>I think I found the problem...
>I noticed when I click on the FIRST row in datagrid then update the data, it get updated.
>BUT, I clicked any row OTHER than the first row it ignores the changes.
>
>I think, the datagrid pointer is not moving to the correct posotion in the dataset!!!
>Don't you think so?
>
>
>
>>Right before you update the child table, look at the RowState property of the DataRows in the child table. See if they are set to modified (value of 16) or Added (value of 4).
>>
>>>>Have you checked the ContinueUpdateOnError property of the DataAdapter as I described in an earlier post? it's already set to False
>>>
>>>Are you calling the AcceptChanges method before the child table has a chance to finish updating all the records? How do I know if child table finished updating or not I am using this code :
>>>
>>>BindingContext(myDS, "Measure").EndCurrentEdit()
>>>myMeasureDA.Update(myDS, "Measure")
>>>myDS.AcceptChanges()
>>>
>>>
>>>What is the status of the child records after the update? I am not using any DataRow for the child table, Iam using datarow for the parent table if I need to update any field maualy not via databindig.
>>>
>>>Does the DataSet still think the records are modified? After I finish updateing I see the new updates in the datagrid as updated it but if I exit and open the form again I see the old data (database not updated)
>>>
>>>Cathi, again thank u for your help & time.
>>>
>>>
>>>>
>>>>>Cathi,
>>>>>I have added the primary keys as follow for the 2 table, but still same problem if the child table has 1 row it updates the data fine, but if I have 2 or more child rows it ignores the changes.
>>>>>Note:
>>>>>1) I am using databinding.
>>>>>2) myDA or myDS are not raising any error, exception.
>>>>>
>>>>>
>>>>>' Add "Member"'s PrimaryKey to myDS
>>>>>Dim MemberPK() As DataColumn = {myDS.Tables("Member").Columns("MemberID")}
>>>>>myDS.Tables("Member").PrimaryKey = MemberPK
>>>>>' Add "Measure"'s PrimaryKey to myDS
>>>>>Dim MeasurePK() As DataColumn = {myDS.Tables("Measure").Columns("Code")}
>>>>>myDS.Tables("Measure").PrimaryKey = MeasurePK
>>>>>
>>>>>
>>>>>Do u think I'm missing something else?
>>>>>
>>>>>
>>>>>>Yes, make sure the DataSet is aware of the keys for each table.
>>>>>>
>>>>>>>Yes, they have a PK but Iam not adding them to my dataset, should I add them to my dataset (parent table as PK and child table as FK)??
>>>>>>>
>>>>>>>
>>>>>>>>I would look at your data and make sure both tables have a primary key.
>>>>>>>>
>>>>>>>>I would also make sure the ContinueUpdateOneError property of the DataAdapter is set to False. If you set this property to True and one or more of the update attempts fail, the DataAdapter will not throw an exception. When the DataAdapter encounters a failed update attempt, it will set the HasErrors property of the corresponding DataRow object to True and set the RowError property of the DataRow to the concurrency error message. You can check the HasErrors property of your DataSet or DataTable after calling DataAdapter.Update to determine whether any of the update attempts failed.
>>>>>>>>
>>>>>>>>
>>>>>>>>>In that case I get un error message:
>>>>>>>>>"Update unable to find TableMapping['Table'] or DataTable 'Table'.
>>>>>>>>>
>>>>>>>>>I need to spacefy the table name as I am doing.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>>Just a guess, Ahmad, since I haven't used either DataRelations or the da.Update(), but why don't you update the DataSet as opposed to the DataTable. So, you'd do this instead:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>da.Update(myDS)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>~~Bonnie
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>Hi All,
>>>>>>>>>>>
>>>>>>>>>>>I have 2 datatable in my dataset and have created a datarelation between the parent & child datatables.
>>>>>>>>>>>
>>>>>>>>>>>If I updated the parent table, the data saved fine, but if updated child table it updates fine (if one row in the relation) but if it has more than one row it egnores the update & does not give any error too. Usig this code:
>>>>>>>>>>>
>>>>>>>>>>>BindingContext(myDS, "Measure").EndCurrentEdit()
>>>>>>>>>>>myMeasureDA.Update(myDS, "Measure")
>>>>>>>>>>>myDS.AcceptChanges()
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>It woks fine if I removed the datarelation before the update !!!
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>myDS.Relations.Remove("MemMsr")
>>>>>>>>>>>BindingContext(myDS, "Measure").EndCurrentEdit()
>>>>>>>>>>>myMeasureDA.Update(myDS, "Measure")
>>>>>>>>>>>myDS.AcceptChanges()
>>>>>>>>>>>
>>>>>>>>>>>But I need the relation, any one knows how to solve this essue.
>>>>>>>>>>>
>>>>>>>>>>>Note: I am using CommandBuilder, & MSDE as backend database
>>>>>>>>>>>
>>>>>>>>>>>Thanks for the help
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform