C# Windows Form ListView concept

J

Jason Huang

Hi,

In my C# Windows Form application, I have a ListView control Lvw1 in MyForm.
For most cases, the Lvw1 has no more than 5 rows of data. But now comes the
situation that one user has to input approximately 100 rows into the Lvw1.

Case1, 5 rows.
Case2, 3 rows.
....
CaseX, 100 rows.

We used to process the Update/Delete as:
DELETE all rows in the Database Table which has the item value CaseX, then
INSERT into the database from the existing rows in Lvw1.
But this seems kind of too risky, I'm thinking is there a better solution
for doing the Update/Delete?

Thanks for help.


Jason
 
N

Nicholas Paldino [.NET/C# MVP]

Jason,

Why is it risky? I mean, that is the logic. Now, if the 100 rows are
going to be constant for case X, then you can get away with an update, but
something tells me that the 100 rows of data will sometimes be 101 rows or
99 rows, or some other variable number. In this case, it makes sense to
just issue the one delete, and then to perform the inserts.

Hope this helps.
 
B

Bruce Wood

Hi,

In my C# Windows Form application, I have a ListView control Lvw1 in MyForm.
For most cases, the Lvw1 has no more than 5 rows of data. But now comes the
situation that one user has to input approximately 100 rows into the Lvw1.

Case1, 5 rows.
Case2, 3 rows.
...
CaseX, 100 rows.

We used to process the Update/Delete as:
DELETE all rows in the Database Table which has the item value CaseX, then
INSERT into the database from the existing rows in Lvw1.
But this seems kind of too risky, I'm thinking is there a better solution
for doing the Update/Delete?

It's only risky if you're not using a transaction. Carry out the
deletes and inserts within a single transaction. That way they will
either all occur, or none will occur.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top