Can anyone tell me what could be causing this problem please.
I made 1 table with an ID field, and a Name field, just for testing.
I made the ID "Key" And "Identity Specification" = "Yes"
Now it made my dataset/adapter/bindingsource whe i pulled over the datagridview from my datasource.
So now when I use the following code to add a row, it works.
Then I call my UpdateFunction
Which looks like this:
Then lets say I wanted to clear all of the rows, when I DatabaseDataSet.Outgoing.Clear(), all the rows disappear from my datagrid but the update function writes 0 to the log which means 0 changes was made to my databse. So I found a way around that by using a foreach to loop through the table, add each row to a List, then loop through the list and remove each row from the databse 1 by 1.
I call my SaveOutDB() function on the Datagrid event of a "Row Removed" and "Cell End Edit" btw.
The problem is when I try to add a new row after deleting everything I get this "DataTable internal index is corrupted: '5'." error and I have to restart my app for it to work again.
I apologize if the post is a bit messy or confusing, please let me know if anything is not clear.
Also, why are all my ID's negative when I first add them, and then they turn positive next time i start the app?
I made 1 table with an ID field, and a Name field, just for testing.
I made the ID "Key" And "Identity Specification" = "Yes"
Now it made my dataset/adapter/bindingsource whe i pulled over the datagridview from my datasource.
So now when I use the following code to add a row, it works.
VB.NET:
Dim outrow As DataRow
outrow = DatabaseDataSet.Outgoing.NewRow()
outrow(1) = scheduled
DatabaseDataSet.Outgoing.Rows.Add(outrow)
Then I call my UpdateFunction
Which looks like this:
VB.NET:
Sub SaveOutDB()
Try
Me.Validate()
Me.OutgoingBindingSource.EndEdit()
Dim update As Integer
update = Me.OutgoingTableAdapter.Update(DatabaseDataSet.Outgoing)
Debug.WriteLine(update.ToString + " changes to database")
OutgoingDataGridView.RefreshEdit()
OutgoingDataGridView.RefreshEdit()
Catch ex As Exception
Writelog(ex.Message)
End Try
End Sub
Then lets say I wanted to clear all of the rows, when I DatabaseDataSet.Outgoing.Clear(), all the rows disappear from my datagrid but the update function writes 0 to the log which means 0 changes was made to my databse. So I found a way around that by using a foreach to loop through the table, add each row to a List, then loop through the list and remove each row from the databse 1 by 1.
I call my SaveOutDB() function on the Datagrid event of a "Row Removed" and "Cell End Edit" btw.
The problem is when I try to add a new row after deleting everything I get this "DataTable internal index is corrupted: '5'." error and I have to restart my app for it to work again.
I apologize if the post is a bit messy or confusing, please let me know if anything is not clear.
Also, why are all my ID's negative when I first add them, and then they turn positive next time i start the app?