If you change this:

DataTable delCustTbl = dataSet.Tables["Customers"];

to this:

DataTable delCustTbl = delDataSet.Tables["Customers"];

Shawn's code works.  I get two rows.  Plus, if you call GetChanges() and no
rows with a matching RowState are found, you get a null reference back, not
an empty DataSet, so I suspect there's another problem with your code - how
about posting it?

Jim

> -----Original Message-----
> From: franklin gray [mailto:[EMAIL PROTECTED]]
> Sent: 02 May 2002 16:45
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] dataset.GetChanges on deleted rows
>
>
> First off, you are only counting the number of rows in the
> original dataset and displaying that.
>
> Second, I had to change your database to northwind and the
> table from Customer to Customers for it to run.  Plus, no
> need to put the server attribute in the connection string if
> it is the local machine.
>
> Now the real problem.
>
> I need to get the deleted rows in XML format, not use them
> with an adapter.  If I use .GetXML from the dataset that has
> the deleted rows, I get basically nothing.  If I try to read
> the contents of the rows in the dataset that has the deleted
> rows, I get something other then the data (I forget what it is).
>
>
> I appreciate the help though.
>
> -----Original Message-----
> From: Shawn Wildermuth [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, May 01, 2002 10:54 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [DOTNET] dataset.GetChanges on deleted rows
>
>
> This works fine for me.  If I have the following code:
>
> // Connect to the database
> SqlConnection conn = new SqlConnection("Server=localhost;" +
>                                         "Database=ADONET;" +
>                                         "Integrated Security=true;");
> SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM
> CUSTOMER", conn);
> conn.Open();
>
> // Fill the DataSet
> DataSet dataSet = new DataSet();
> da.Fill(dataSet, "Customers");
>
> // Delete some rows
> DataTable custTbl = dataSet.Tables["Customers"];
> custTbl.Rows[0].Delete();
> custTbl.Rows[1].Delete();
>
> // Get the Deleted Rows
> DataSet delDataSet = dataSet.GetChanges(DataRowState.Deleted);
>
> // Try and show the deleted rows
> DataTable delCustTbl = dataSet.Tables["Customers"];
> Console.Write("Deleted Rows: {0}", delCustTbl.Rows.Count);
>
> I get Delted Rows: 2
>
> Thanks,
>
> Shawn Wildermuth
> [EMAIL PROTECTED]
>
> > -----Original Message-----
> > From: dotnet discussion [mailto:[EMAIL PROTECTED]]
> > On Behalf Of franklin gray
> > Sent: Wednesday, May 01, 2002 5:21 PM
> > To: [EMAIL PROTECTED]
> > Subject: [DOTNET] dataset.GetChanges on deleted rows
> >
> >
> > Has anybody gotten this to work right?  I get an empty
> > dataset.  The rows have been deleted, not removed.
> >
> > TempDS = Me.DS.GetChanges(DataRowState.Deleted)
> >
> > You can read messages from the DOTNET archive, unsubscribe
> > from DOTNET, or subscribe to other DevelopMentor lists at
> > http://discuss.develop.com.
> >
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>
> You can read messages from the DOTNET archive, unsubscribe
> from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to