By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,465 Members | 1,501 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,465 IT Pros & Developers. It's quick & easy.

DatasetCounter - DataGridView Problem - VS2005, C#

P: n/a
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 <saveand 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
Jul 9 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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 <saveand 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
Jul 9 '08 #2

P: n/a
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
Jul 10 '08 #3

P: n/a
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
Jul 10 '08 #4

P: n/a
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
Jul 10 '08 #5

P: n/a
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 Mller" <po******@arcor.dewrote in message
news:72**********************************@e39g2000 hsf.googlegroups.com...
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
Jul 10 '08 #6

P: n/a
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 Mller" <post2...@arcor.dewrote 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

Jul 10 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.