Advertisement

06.07.2008 at 05:59AM PDT, ID: 23465982
[x]
Attachment Details

Insert a row inro an existing dataset

Asked by grwallace in Visual Studio .NET 2005, ADO.Net Class Library

Tags: vb.net 2008

I have a dataset retrieved from a database and need to add a row to it under certain conditions. I have the code:-
Try
            With Me.DStrn.Tables("Transactions")
                For Each DR In .Rows
                    If DR.Item("XactType") = 3 And DR.Item("VatDiscAmt") <> 0 Then
                        HoldDisc = DR.Item("VatDiscAmt")
                        DR = DStrn.Tables("Transactions").NewRow
                        DR("AlphType") = "Disc."
                        DR("TotalPosting") = HoldDisc
                        DR("TrnId") = 0
                        DR("InvSource") = ""
                        DR("XactDate") = Today
                        DR("XactType") = 0
                        DR("XactStatus") = 0
                        DR("OurRef") = ""
                        DR("YourRef") = ""
                        DR("LoadCard") = ""
                        DR("PaymtDueDate") = Today
                        DR("AlphType") = ""
                        DR("NonDiscTotal") = HoldDisc
                        DR("RunningBal") = -99999999.99
                        DR("AmountAllocated") = 0
                        DR("VatDiscAmt") = 0
                        DStrn.Tables("Transactions").Rows.InsertAt(DR, 0)
                       
                    End If
                Next
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

his comes up with an exception message "Collection was Modified; enumeration operation might not execute and bombs me out,

Any ideas anyone?Start Free Trial
[+][-]06.07.2008 at 06:27AM PDT, ID: 21735370

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 06:57AM PDT, ID: 21735482

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 07:03AM PDT, ID: 21735504

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 07:30AM PDT, ID: 21735656

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 07:33AM PDT, ID: 21735665

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 07:36AM PDT, ID: 21735689

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 07:39AM PDT, ID: 21735698

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio .NET 2005, ADO.Net Class Library
Tags: vb.net 2008
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628