Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, all.

I am trying Data Table Row delete or remove with vb .net, but i have some problem on Auto increment update after deleting Datatype Row.Kindly refer to the followings for my question.

I am using Local ".csv" file for DB handling.

1. I make one Data Table with one Auto increment Column.

2. In adding Data Table Row case, there is not problem updating Auto increment value.

3. In deleting Data Table Row case, there is problem on Updating Auto increment value.That means, after deleting or removing the Data Table Row, Auto Increment value is not updated.

For example, i want auto numbering auto increment column value as like 1, 2, 3, 4, 5... after deleting some row. But now, i have result disconnected numbering as like 1, 2, 4, 5... after deleting 3rd row.I have searched relation issue but i can't find some solution.Kindly anyone help me.The following is my current source.
C#
DataSet.Tables("TableName").Rows.RemoveAT(RowIndex)

DataSet.AcceptChanges()

DataGridView.DataSource = DataSet.Tables("TableName")
Posted
Updated 17-Nov-13 17:48pm
v5
Comments
Garth J Lancaster 17-Nov-13 22:09pm    
Im sorry, I think it is your expectation/use that is wrong

It is entirely correct that the sequence is 1,2,4,5 after deleting the 3rd row - autoincrement is usually used to provide a unique primary key - not indicate the 'n'th row in a table - if you're expecting behaviour like this, then you're really going to be annoyed if you return a sorted query on the table !

Please explain what you're trying to achieve and why 'disconnected numbering' is wrong, and someone may beable to suggest an alternative
Ganesh KP 17-Nov-13 23:26pm    
The output you have shown is the expected output and AutoIncrement will increment automatically when u add a row and it will not decrement or re-adjust with other rows if you going to delete any rows. If you want to achieve that behavior then you have to use another column with Row_Index and you have to do manually every time when u update/delete the row. Offcourse you can run a script every time when you perform an update/delete operation which does the Row_Index set automatically.
dolbol 17-Nov-13 23:53pm    
Thnaks for your recommendation and I am sorry on my mistake in my source.
Kindly again refer to the my source : RemoveAT("ColumnName") => RemoveAT(RowIndex)
If you have some time loss by my mistake, I am sorry.

Before start my source coding, I really can't think that issue bother to me.
Anyway, thanks for your comments. If you have some solution on that issue, kindly inform to me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900