PC Review


Reply
Thread Tools Rate Thread

DatasetCounter - DataGridView Problem - VS2005, C#

 
 
Andrea Müller
Guest
Posts: n/a
 
      9th Jul 2008
Hello,

I have one problem.
Include my project is a dataset with tables.
During my process I create a new temporary table.

The dataset use my DataGrid Control.

The use delete now one, two or more rows.
After that the operator press <save> and I create the new table with
some Reference,
from the table, which the operator deleted.

I go through the table and I see all deleted rows.
Why?
What can I do?
I need not Transmit and Rollback...

If the operator deletes the lines, these are to be deleted.

dataSetDatabase.Query ?? it does not give
dataSetDatabase.ReQuery ?? it does not give
dataSetDatabase.Update ?? it does not give

I need AccepteChanges, yes or no?



A bad solution is that.
My attempt.
dataSetDatabase.tblSequence.Clear();
dataSetDatabase.WriteXml( filename );

dataSetDatabase.Clear();
dataSetDatabase.ReadXml( filename );
create the new table.


Can everybody help me?
Thanks for help.
Regards,
Andrea
 
Reply With Quote
 
 
 
 
Ciaran O''Donnell
Guest
Posts: n/a
 
      10th Jul 2008
You need to be a little clearer with your question.
Are you saying that the user deletes rows from your dataset through a
datagrid control and you arent seeing those changes in the database when you
call DataAdapter.Update()?

Let me know exactly the problem so I can help more.


--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com


"Andrea Müller" wrote:

> Hello,
>
> I have one problem.
> Include my project is a dataset with tables.
> During my process I create a new temporary table.
>
> The dataset use my DataGrid Control.
>
> The use delete now one, two or more rows.
> After that the operator press <save> and I create the new table with
> some Reference,
> from the table, which the operator deleted.
>
> I go through the table and I see all deleted rows.
> Why?
> What can I do?
> I need not Transmit and Rollback...
>
> If the operator deletes the lines, these are to be deleted.
>
> dataSetDatabase.Query ?? it does not give
> dataSetDatabase.ReQuery ?? it does not give
> dataSetDatabase.Update ?? it does not give
>
> I need AccepteChanges, yes or no?
>
>
>
> A bad solution is that.
> My attempt.
> dataSetDatabase.tblSequence.Clear();
> dataSetDatabase.WriteXml( filename );
>
> dataSetDatabase.Clear();
> dataSetDatabase.ReadXml( filename );
> create the new table.
>
>
> Can everybody help me?
> Thanks for help.
> Regards,
> Andrea
>

 
Reply With Quote
 
Andrea Müller
Guest
Posts: n/a
 
      10th Jul 2008
Hello,
>call DataAdapter.Update()?
>Let me know exactly the problem so I can help more.


I call the Update never, because the dataSetDatabase have no Update
function.

DATASET ---------------- DataGridView for the User
Record Set exist -------
10 Recordset inside -- User see 10 Recordset --> fine all ok
10 Recordset inside -- User delete for example 2 --> Use see
8

The problem now. In the Dataset not 8 recordset, also 10, why? It is
stupid.

That is my problem.

Regards Andrea
 
Reply With Quote
 
Ciaran O''Donnell
Guest
Posts: n/a
 
      10th Jul 2008
Ok I think the problem might be that the DataSet holds on to the rows you
delete but marks them as deleted in the dataset with the row.RowState
property. This enables it to know which records to delete if you used a
DataAdapter to update the database.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com


"Andrea Müller" wrote:

> Hello,
> >call DataAdapter.Update()?
> >Let me know exactly the problem so I can help more.

>
> I call the Update never, because the dataSetDatabase have no Update
> function.
>
> DATASET ---------------- DataGridView for the User
> Record Set exist -------
> 10 Recordset inside -- User see 10 Recordset --> fine all ok
> 10 Recordset inside -- User delete for example 2 --> Use see
> 8
>
> The problem now. In the Dataset not 8 recordset, also 10, why? It is
> stupid.
>
> That is my problem.
>
> Regards Andrea
>

 
Reply With Quote
 
Andrea Müller
Guest
Posts: n/a
 
      10th Jul 2008
Hello Ciaran,
> Ok I think the problem might be that the DataSet holds on to the

rows you
> delete but marks them as deleted in the dataset with the row.RowState
> property. This enables it to know which records to delete if you used a
> DataAdapter to update the database.
> --

so I can check the state.

If the state row.RowState == Deleted I can go one row further.
Correct?

Or maybe with Commit o Rollback .... ?

Regards Andrea


private void DemonstrateRowState()
{
// Run a function to create a DataTable with one column.
DataTable table = MakeTable();
DataRow row;

// Create a new DataRow.
row = table.NewRow();
// Detached row.
Console.WriteLine("New Row " + row.RowState);

table.Rows.Add(row);
// New row.
Console.WriteLine("AddRow " + row.RowState);

table.AcceptChanges();
// Unchanged row.
Console.WriteLine("AcceptChanges " + row.RowState);

row["FirstName"] = "Scott";
// Modified row.
Console.WriteLine("Modified " + row.RowState);

row.Delete();
// Deleted row.
Console.WriteLine("Deleted " + row.RowState);
}

http://msdn.microsoft.com/en-us/libr....rowstate.aspx
 
Reply With Quote
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      10th Jul 2008
If you really only want to work with the modified DataSet and do not care
about updating the database, you can call the GetChanges method.
Peter
"Andrea Müller" <(E-Mail Removed)> wrote in message
news:72e399e4-496f-40c1-8ec1-(E-Mail Removed)...
> Hello Ciaran,
> > Ok I think the problem might be that the DataSet holds on to the

> rows you
>> delete but marks them as deleted in the dataset with the row.RowState
>> property. This enables it to know which records to delete if you used a
>> DataAdapter to update the database.
>> --

> so I can check the state.
>
> If the state row.RowState == Deleted I can go one row further.
> Correct?
>
> Or maybe with Commit o Rollback .... ?
>
> Regards Andrea
>
>
> private void DemonstrateRowState()
> {
> // Run a function to create a DataTable with one column.
> DataTable table = MakeTable();
> DataRow row;
>
> // Create a new DataRow.
> row = table.NewRow();
> // Detached row.
> Console.WriteLine("New Row " + row.RowState);
>
> table.Rows.Add(row);
> // New row.
> Console.WriteLine("AddRow " + row.RowState);
>
> table.AcceptChanges();
> // Unchanged row.
> Console.WriteLine("AcceptChanges " + row.RowState);
>
> row["FirstName"] = "Scott";
> // Modified row.
> Console.WriteLine("Modified " + row.RowState);
>
> row.Delete();
> // Deleted row.
> Console.WriteLine("Deleted " + row.RowState);
> }
>
> http://msdn.microsoft.com/en-us/libr....rowstate.aspx


 
Reply With Quote
 
Andrea Müller
Guest
Posts: n/a
 
      10th Jul 2008
Hello Peter,
> If you really only want to work with the modified DataSet and do not care
> about updating the database, you can call the GetChanges method.
> Peter"Andrea Müller" <post2...@arcor.de> wrote in message


public static void CreateSequences(DataSetRDatabase db)
{
db.tblSequence.Clear();

foreach ( DataSetRDatabase.tblProductRow rowProduct in
db.tblProduct )
{
int idProduct = rowProduct.ProductRef;

The operator delete one or more rows in the DataGridView.
After then the operator press SAVE and I create a new sequence table.
So, the rowProduct is deleted.

GetChanges told me changes yes or no, if yes then....?
Have you a example?

Regards Andrea

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VS2005 with DataGridView. tom Microsoft VB .NET 0 30th Nov 2006 04:42 AM
DataGridView (VS2005) vbt Microsoft VB .NET 3 28th Nov 2006 06:36 AM
Vs2005 datagridview bug. Bob Microsoft VB .NET 1 7th Jan 2006 04:43 PM
VS2005 DataGridView problem Fernando Cardoso Microsoft Dot NET Framework Forms 1 24th Nov 2005 04:11 AM
VS2005 Another DataGridView Problem Fernando Cardoso Microsoft Dot NET Framework Forms 1 18th Nov 2005 01:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 PM.