I'm trying to add a row to my dataset using the following:

Dim foundRow As DataRow = DsMembers.Members.NewRow
        foundRow("FirstName") = scannedMember.FirstName
        foundRow("MiddleName") = scannedMember.MiddleName
        foundRow("LastName") = scannedMember.LastName
        foundRow("Address") = scannedMember.Address
        foundRow("City") = scannedMember.City
        foundRow("State") = scannedMember.State
        foundRow("Zip") = scannedMember.Zip
        foundRow("DOB") = scannedMember.DOB
        foundRow("TDL") = scannedMember.TDL
        foundRow("MemberID") = scannedMember.MemberID
        foundRow("DateJoined") = scannedMember.DateJoined
        foundRow("DateExpired") = scannedMember.DateExpired
        If scannedMember.Barred <> Nothing Then
            foundRow("Barred") = scannedMember.Barred
            If scannedMember.Barred = "Y" Then
                foundRow("BarredReason") = scannedMember.BarredReason
            End If
            foundRow("Barred") = "N"
            foundRow("BarredReason") = " "
        End If
        DsMembers.Members.Rows.Add(foundRow) '.AddMembersRow(foundRow)

For some reason, even though the rowState says "Added", the row is never added to the dataset. If I run


after calling AcceptChanges it doesn't find anything. Any ideas? Thanks!

Did you check rows.count before and after adding the row?

console.Writeline( "Rows.Count {0}", DsMembers.Members.Rows.Count )

Do you assign the result of the find to a datarow?

Dim rowFound As DataRow = DsMembers.Members.FindByTDL(scannedMember.TDL)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.