I'm using asp.net 2.0 and C#. I have a data entry web form that contains a formview that is bound to a cpDataSource. The cpDataSource specifies an 'InsertMethod' that is contained in a db access class.
The web form contains alot of textboxes but also contains two CheckBoxList's. Each CheckBoxList is associated with a child table. When the user clicks the 'Save' button, the data in the form will get saved to the database via the 'InsertMethod' that calls a stored procedure in the database (SQLServer). This saves the parent data on the form. I then have a cpDataSource_Inserted method defined OnInsert that will cycle through each CheckBoxList and save the child records accordingly if the checkboxes are checked.
My question is: This method that I am using works, but if the db were to go down after the parent data is saved but before the child data is saved, I will have inconsistent data in the database. Is there a better way of doing this?
I could have the stored procedure save everything and start a transaction at the beginning. I'm rusty on SQLServer so not sure if you can do that, but I wanted to find out the best practice in doing this standard type of thing.
Thanks,
Jan
The web form contains alot of textboxes but also contains two CheckBoxList's. Each CheckBoxList is associated with a child table. When the user clicks the 'Save' button, the data in the form will get saved to the database via the 'InsertMethod' that calls a stored procedure in the database (SQLServer). This saves the parent data on the form. I then have a cpDataSource_Inserted method defined OnInsert that will cycle through each CheckBoxList and save the child records accordingly if the checkboxes are checked.
My question is: This method that I am using works, but if the db were to go down after the parent data is saved but before the child data is saved, I will have inconsistent data in the database. Is there a better way of doing this?
I could have the stored procedure save everything and start a transaction at the beginning. I'm rusty on SQLServer so not sure if you can do that, but I wanted to find out the best practice in doing this standard type of thing.
Thanks,
Jan