datagrid editing

M

Mike P

I have a datagrid with a 'Delete' column that the user can click on to
delete a row in the datagrid. I thought that I would need to have some
kind of error handling in case somebody goes into the database table
that the datagrid uses and deletes a record while the user is still
viewing the record in their datagrid, since if they then press 'Delete'
on a record that has since been deleted from the table, a concurrency
error should occur. But after trying this, no error is raised at all,
on pressing 'Delete' the record is simply removed from the datagrid.
Does anybody know why this happens? And do I therefore not need to
provide error handling for this?


Cheers,

Mike
 
M

martin

most likely you have removed the record from the datagrid or the underlaying
dataset and then not bound back to the database table.

you need to delete from the database table and the rebind the datagrid.

if you are deleting from the database using a command such as

"Delete from mytable where record=deletevalue"

and this record does not exist in the db then you will not get an error. It
is best to check the rowcount property (usually in the db) to actually
ensure that 1 row was deleted.
although you may think not deleting a row is an error, the database does
not.

hope I have understood you correctly.

cheers

martin
 
M

Mike P

Martin,

I just wondered if I should be getting an error even though I wasn't.
I'm using direct SQL 'DELETE * FROM Table WHERE ID = ", so if this isn't
actually meant to generate an error, it is probably OK to leave my code
as it is...there's no need to inform the user that the record was
deleted by somebody else, as long as it is deleted.


Thanks,

Mike
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top