Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleted row information cannot be accessed through the r
Message
De
27/02/2006 15:46:43
 
 
À
27/02/2006 13:34:18
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
C# 2.0
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01098407
Message ID:
01099645
Vues:
16
Cetin,

I don't see how the underlying datasource has any impact on this at all. All I'm saying is that once you do a DataSet.AcceptChanges(), the DataSet will no longer have any changes. There will be no way to know what needs to be updated. DataSet.HasChanges() will return false.

~~Bonnie



>Bonnie,
>You were very confident saying it's not correct I couldn't even dare to object:) I think it's not very incorrect and situation arises from the fact that underlying source have trigger(s) that effect other tables in dataset. When I have time I hope to come back with a sample code:) For now as you said I accept it's not correct.
>Cetin
>
>>Hmmm, I'm going to have to revise that last answer ... I don't use the .Update() command (I do my own updates), and so I forgot that a DataAdapter.Update() does an automatic DataSet.AcceptChanges() after it successfully updates, so my suggestion to do it after the .Update() won't do much good.
>>
>>Are you sure there's no additional code in the .Click event that you didn't show us? Or is it possible that your .Update() failed for some reason and the .AcceptChanges() wasn't performed?
>>
>>In any case, I think we need more information to help you solve this.
>>
>>~~Bonnie
>>
>>
>>
>>>>acceptchanges first. Better yet move update to another place so you have a chance to accept or reject pending deletions.
>>>
>>>No Cetin, that's not correct ... if he does .AcceptChanges() before the .Update(), the .Update will not think there are any changes to be sent to the database.
>>>
>>>Rene, I think the problem might not actually be the .Update(), but somewhere else in your program after you've updated and then you try to access the Deleted row. Cetin was halfway correct <g> ... do the .AcceptChanges() after you do the .Update().
>>>
>>>~~Bonnie
>>>
>>>
>>>
>>>>>Hi All,
>>>>>
>>>>>I have encountered error "'Deleted row information cannot be accessed through the row." when saving data.
>>>>>
>>>>>Below is the sample of my code.
>>>>>
>>>>>
>>>>>using System;
>>>>>using System.Drawing;
>>>>>using System.Collections;
>>>>>using System.ComponentModel;
>>>>>using System.Windows.Forms;
>>>>>using System.Data;
>>>>>using System.Data.SqlClient;
>>>>>using System.Data.OleDb;
>>>>>
>>>>>namespace SampleCode
>>>>>{
>>>>> ///
>>>>> /// Summary description for Form1.
>>>>> ///

>>>>> public class Form1 : System.Windows.Forms.Form
>>>>> {
>>>>> private System.Windows.Forms.Button buttonLoad;
>>>>> private System.Windows.Forms.Button buttonDelete;
>>>>>
>>>>> private SqlConnection objCnn = new SqlConnection("server=dbasrv03;Trusted_Connection=yes;database=northwind");
>>>>> private SqlDataAdapter objDataAdapter = new SqlDataAdapter();
>>>>> private DataSet objDataSet = new DataSet();
>>>>> private DataRow objDataRow;
>>>>> private SqlParameter workParam = null;
>>>>>
>>>>> // some c# generated code
>>>>>
>>>>> private void buttonLoad_Click(object sender, System.EventArgs e)
>>>>> {
>>>>> string lcSqlCmd;
>>>>>
>>>>> lcSqlCmd = "Select RegionID, RegionDescription from Region where RegionID = 123" ;
>>>>> objDataAdapter.SelectCommand = new SqlCommand(lcSqlCmd, objCnn);
>>>>> objDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
>>>>> objDataAdapter.Fill(objDataSet, "Region");
>>>>> objDataRow = objDataSet.Tables["Region"].Rows.Find(1);
>>>>> }
>>>>> private void buttonDelete_Click(object sender, System.EventArgs e)
>>>>> {
>>>>> objDataSet.Tables["Region"].Rows[0].Delete();
>>>>> objDataAdapter.Update(objDataSet, "Region");
>>>>> }
>>>>> }
>>>>>}
>>>>>
>>>>>Any idea about this problem.
>>>>>The error occurs when i click the delete button.
>>>>>
>>>>>TIA,
>>>>>
>>>>>Rene
>>>>
>>>>acceptchanges first. Better yet move update to another place so you have a chance to accept or reject pending deletions.
>>>>Cetin
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform