datagrid concurrency violation 
Author Message
 datagrid concurrency violation

Help!

i have a datagrid on a form, which is populated from a
datset, everything works fine.. updates/edit/new lines
etc, but i want to be able to delete a row by clicking a
button on the datagrid.

so once the data has been loaded, i added a column using
the code below;

' create, add and set the deletion column
Dim dColumn As New DataColumn("REMOVE")
dColumn.DataType = System.Type.GetType("System.Boolean")

' add the column
DsCodes1.codes.Columns.Add(dColumn)
' go through each row in the column and set it to false
Dim dRow As DataRow
For Each dRow In DsCodes1.codes
   dRow("REMOVE") = False
Next

so far so good.. i have added code so when the user clicks
the checkbox on the REMOVE column it removes it from the
dataset... still works

But when i call the update statement, i get the following
error;

System.Data.DBConcurrencyException: Concurrency violation:
the UpdateCommand affected 0 records.

even though i have removed row, edited them, or even added
new ones!

when i remove the extra column it works fine!

Can anyone help me! i must be missing something, is there
no easy way to remove a row in a datagrid?

Thanks

Roland



Fri, 04 Nov 2005 19:34:20 GMT  
 datagrid concurrency violation
To my knowledge, the datatable and the original databse table need to have
the same columns in them in order for the Update to work correctly. That is
why adding a column causes the problem.

As a test, modify the SQL Server table and add the column and a Default
value.
Then they will match and you should be able to Update.
--
Joe Fallon


Quote:
> Help!

> i have a datagrid on a form, which is populated from a
> datset, everything works fine.. updates/edit/new lines
> etc, but i want to be able to delete a row by clicking a
> button on the datagrid.

> so once the data has been loaded, i added a column using
> the code below;

> ' create, add and set the deletion column
> Dim dColumn As New DataColumn("REMOVE")
> dColumn.DataType = System.Type.GetType("System.Boolean")

> ' add the column
> DsCodes1.codes.Columns.Add(dColumn)
> ' go through each row in the column and set it to false
> Dim dRow As DataRow
> For Each dRow In DsCodes1.codes
>    dRow("REMOVE") = False
> Next

> so far so good.. i have added code so when the user clicks
> the checkbox on the REMOVE column it removes it from the
> dataset... still works

> But when i call the update statement, i get the following
> error;

> System.Data.DBConcurrencyException: Concurrency violation:
> the UpdateCommand affected 0 records.

> even though i have removed row, edited them, or even added
> new ones!

> when i remove the extra column it works fine!

> Can anyone help me! i must be missing something, is there
> no easy way to remove a row in a datagrid?

> Thanks

> Roland



Sat, 05 Nov 2005 10:06:05 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Concurrency Violation in VB.NET

2. VB 6.0 Memory Access Violation (in OLEDB32) on exit sub AfterUpdate event of DataGrid

3. Need some help with DataGrids (DataGrid-->DataGrid, DataGrid-->Dataset, DataGrid-->XML)

4. MS Access and SQL Server concurrency?

5. Problem using "timestamp" for concurrency control

6. Concurrency issues with Shared Contacts

7. License and Concurrency Stragies

8. concurrency errors

9. concurrency problems with Public Shared methods and variables

10. Concurrency Errors with Access - VB.NET - ADO

11. Concurrency Error using Access

12. Strange RowState/Concurrency Manager behavior

 

 
Powered by phpBB® Forum Software