471,337 Members | 1,165 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

DatasetCounter - DataGridView Problem - VS2005, C#

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
6 1796
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
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
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
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
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
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.

Similar topics

1 post views Thread by Brian | last post: by
10 posts views Thread by michael sorens | last post: by
7 posts views Thread by Mitchell S. Honnert | last post: by
reply views Thread by vbt | last post: by
reply views Thread by tom | last post: by
3 posts views Thread by =?Utf-8?B?Sm9obiBCdW5keQ==?= | last post: by
6 posts views Thread by hzgt9b | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.