Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts,
I hope you can help me.
I have 12 datatables in my VB.net code.
I have to add in the first table on an event a recordset. It works.

If the number of recordsets in the first table is above 60, I have to take the oldest recordset and transfer it to the second table. If the second table contains after this more than 60, I have to transfer again the oldest one into the next table.

VB
Do Until QuellTabelle.Rows.Count = Pulse

            Dim DT As DataRow = ZielTabelle.NewRow
            'Debug.Print(QuellTabelle.Rows(0).Item(1))
            Dim ODR As Integer

            For ODR = 0 To ZielCol Step 1 
                DT.Item(ODR) = QuellTabelle.Rows(0).Item(ODR)
            Next ODR

            DT(Präfix_Ziel & "_Start") = CDate(Now) 
            DT(Präfix_Ziel & "_Temp") = CDbl(QuellTabelle.Rows(0).Item(Präfix_Quelle & "_Temp"))
            ZielTabelle.Rows.Add(DT)

            QuellTabelle.Rows(0).Delete()

        Loop



It works for the transfer from the first one to the second one really good. But from the second to the third I always get an error:
The problem is, that the QuellTabelle.Rows.Count does not change. And I do not understand why. What do I have to do after the delete command?

Thanks in advance!
Posted
Comments
Dave Kreskowiak 28-Jan-14 13:34pm    
Incomplete question. We have no idea what you're doing overall.

Also, you don't specific what the error message is.

Third, after the Delete, you have to commit the changes to the database. Delete only tags that record to be deleted in the DataTable (QuellTabelle). It does not commit that change to the database. You have to provide the code to do that. This is usually done with a DataAdapter, the one you possibly used to populate the DataTable in the first place.

Yeah...I have no idea what you are doing...but maybe you are looking for this:
DataTable.AcceptChanges[^]
 
Share this answer
 
Try This :
VB
DataTable.AcceptChanges();
 
Share this answer
 

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