fraggelsmurf
New member
Hi,
I am working on a library database in VB.NET (framework 2.0). My main file has a datagrid connected to a dataset with all the records from an Access 2000 database. I want to be able to edit the data in this datagrid and in the dataset and save the changes to the DB. But i get 3 kind of errors when I add new rows and then delete/modify them:
- Concurrency Violation
- IndexOutOfRangeException (datagridview)
- "Delete row information cannot be accessed through the row"
Since I have used the graphical editor in MS VB 2005 Express Edition to create datagrids, datasets, dataadapters, bindingsources and more. I have little idea what the problem might be. I know that it works if i fill the dataset after each edit but that would slow it down way too much since i got bunch of records and each record has 39 columns.
To update the DB i use following code:
The key is an incremental integer which i have set to go negative in the datagrid/dataset. When i add a new record, i first save all values except key to DB, then I retrieve the correct key from DB and add it to the dataset/datagrid. When doing this, I can't use the normal update so I use acceptchanges instead (EditDB.LibraryDBDataSet.LIBRARY.AcceptChanges()).
I don't know what to do, I am way to fresh to VB.NET to understand how the ADO.NET architecture works. Please point me to the right direction.
Some extra code:
For deleting:
For adding new row:
I am working on a library database in VB.NET (framework 2.0). My main file has a datagrid connected to a dataset with all the records from an Access 2000 database. I want to be able to edit the data in this datagrid and in the dataset and save the changes to the DB. But i get 3 kind of errors when I add new rows and then delete/modify them:
- Concurrency Violation
- IndexOutOfRangeException (datagridview)
- "Delete row information cannot be accessed through the row"
Since I have used the graphical editor in MS VB 2005 Express Edition to create datagrids, datasets, dataadapters, bindingsources and more. I have little idea what the problem might be. I know that it works if i fill the dataset after each edit but that would slow it down way too much since i got bunch of records and each record has 39 columns.
To update the DB i use following code:
VB.NET:
If Me.LibraryDBDataSet.HasChanges Then
Try
Me.LIBRARYTableAdapter.Update(Me.LibraryDBDataSet)
Catch ex As Exception
MsgBox(ex.Message, , "Save Error")
End Try
End If
The key is an incremental integer which i have set to go negative in the datagrid/dataset. When i add a new record, i first save all values except key to DB, then I retrieve the correct key from DB and add it to the dataset/datagrid. When doing this, I can't use the normal update so I use acceptchanges instead (EditDB.LibraryDBDataSet.LIBRARY.AcceptChanges()).
I don't know what to do, I am way to fresh to VB.NET to understand how the ADO.NET architecture works. Please point me to the right direction.
Some extra code:
For deleting:
VB.NET:
EditDB.LibraryDBDataSet.LIBRARY.Rows(currentRow).Delete()
For adding new row:
VB.NET:
EditDB.LibraryDBDataSet.LIBRARY.Rows.Add(row)