hi all,
here's the situation... i have a form and a number of textboxes.
this form only allows single record transaction meaning it can only edit, delete and insert 1 record at a time since it only displays 1 record at a time.
i have already set my adapter's insertcommand, updatecommand and deletecommand.
the deletecommand and updatecommand works perfectly well. the problem i'm having is with the insertcommand... based on further research and studying, my insertcommand does not have any syntax errors because if i bind my datatable to a datagrid and use the insertcommand, it works ok.
anyways, i get a concurrency error when i use the insertcommand.
here's how the form works...
at form_load, i bind my textboxes to my datatable. i have a first, previous, next and last record buttons which allows me to navigate to my datatable. it works ok. i also have a save, delete, add button...
here's how the save and delete button works...
when i delete a record by pressing the delete button, it wont delete the record from my database but it will delete it from my datatable... to delete the record completely i click on the save button which has the adapter.Update(datatable) code... same goes when i edit a field, i need to press save for changes to take effect of course.
now for the add button i have the datatable.defaultview.addnew .., when i press the add button, i also place codes that will clear the fields of their text coz somehow it doesnt do it automatically. then i will try to enter data that is supposed to be considered as a new record... then i press save... thats when i get the concurrency error.
from what i understand, what happens is when i clear the text of the textboxes and then enter new data, i am changing data in the current row index which the datatable thinks i am editing the current record. and since i am also changing the value of the primary key, it causes the concurrency error.
my question is how can i make this datatable.defaultview.addnew work.? i've been trying to find a way to go the row index of the newly created record made by this datatable.defaultview.addnew code. using the datatable.defaultview.position doesnt seem to work.
can anyone help? thanks.
here's the situation... i have a form and a number of textboxes.
this form only allows single record transaction meaning it can only edit, delete and insert 1 record at a time since it only displays 1 record at a time.
i have already set my adapter's insertcommand, updatecommand and deletecommand.
the deletecommand and updatecommand works perfectly well. the problem i'm having is with the insertcommand... based on further research and studying, my insertcommand does not have any syntax errors because if i bind my datatable to a datagrid and use the insertcommand, it works ok.
anyways, i get a concurrency error when i use the insertcommand.
here's how the form works...
at form_load, i bind my textboxes to my datatable. i have a first, previous, next and last record buttons which allows me to navigate to my datatable. it works ok. i also have a save, delete, add button...
here's how the save and delete button works...
when i delete a record by pressing the delete button, it wont delete the record from my database but it will delete it from my datatable... to delete the record completely i click on the save button which has the adapter.Update(datatable) code... same goes when i edit a field, i need to press save for changes to take effect of course.
now for the add button i have the datatable.defaultview.addnew .., when i press the add button, i also place codes that will clear the fields of their text coz somehow it doesnt do it automatically. then i will try to enter data that is supposed to be considered as a new record... then i press save... thats when i get the concurrency error.
from what i understand, what happens is when i clear the text of the textboxes and then enter new data, i am changing data in the current row index which the datatable thinks i am editing the current record. and since i am also changing the value of the primary key, it causes the concurrency error.
my question is how can i make this datatable.defaultview.addnew work.? i've been trying to find a way to go the row index of the newly created record made by this datatable.defaultview.addnew code. using the datatable.defaultview.position doesnt seem to work.
can anyone help? thanks.