Dataset LINQ Question

jsurpless

Well-known member
Joined
Jul 29, 2008
Messages
144
Programming Experience
Beginner
Hi all

I've got a dataset (populated from an XML) and I searching one of its tables using LINQ... here's what I'm doing...

VB.NET:
MatchMakerXML_DataTable = MatchMakerXML_Dataset.Tables("COMPONENT_MATCH")

'Identify Database Component Table field (as per MatchMaker XML)
Dim MatchMakerXML_Query = From Match In MatchMakerXML_DataTable.AsEnumerable() Select Match _
    Where (Match.Field(Of String)("AUTOCAD") = strSearchString)

For Each Match In MatchMakerXML_Query

   strAutoCAD_Block_Attribute_Database = Match.Field(Of String)("DATABASE")

Next

As you can see, I am searching for a string with a value of 'strSearchString'... what's happening is that I run this code several times and it seems that each successive load into the 'MatchMakerXML_DataTable' is being appended... is that what I am doing? I say this because the match count on my query seems to increment by one each pass...

I'm able to eliminate this by placing 'MatchMaker_DataTable = Nothing' before the DataSet.load command...

Thanks!
 
OK... turns out that I'm not clearing the dataset object that I'm creating by table from each run time...

I'm using this code

VB.NET:
MyDataSet.ReadXml(XMLFilePath)

This apparently keeps appending the contents of the XML file into the dataset each iteration... so I figured I'd dispose of the dataset using

VB.NET:
MyDataSet.dispose

but this does nothing...

Any thoughts?
 
Back
Top