Multi Dimension Arraylists

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im pretty new to VB.Net and from what i understand arraylists are the same thing as vectors. Basically, Dynamic arrays. Now, here is my situation. Im working with databases, and i temporarily store my information in arrays to do things like duplication checking or prepping for inserting into the database. I really like the idea of arraylists, because theyre so dynamic. Im going to be dealing with tens of thousands of records and i cant be redim-ing arrays to massive sizes that might never be filled all the way. (i tried it that way, and my program would use about 200MB of RAM).

maybe im not fully understanding how to insert things into the array though. i can do a simple
myArray.Add("Hello") and it will work. But when i try to pull information from a datareader like this:

<h5>While x < dr.FieldCount</h5><h5>                drDataTypes(x, 1).Add(dr.GetDataTypeName(x).ToString)</h5><h5>                drDataTypes(x, 2).Add(dr.GetName(x).ToString)</h5><h5>                x += 1</h5><h5>End While</h5>
i get a NullReferenceException Error.
If i try this with just a normal array of type string, it works fine. Ive looked for a howto or tutorial on how to use arraylists with more than one dimension, but i havent really found anything. The reason im wanting to use arraylists, is because im also going to be using them to store records from a database, clean the records(look for duplication), then insert them into a clean table.

im also not understanding how to do comparisons. for instance i try to set an if statement like this:
<h5>If dupRecord(ckrow, fldnms.IndexOf(fldnms, "MOD_DT")) > dupRecord(row, fldnms.IndexOf(fldnms, "MOD_DT")) Then checks modification dates
 dupRecord(ckrow, 1).RemoveAt(ckrow)delete the record from the arraylist
Else
  dupRecord(row, 1).RemoveAt(row) delete the record from the arraylist
end if</h5>

i get a syntax error of, "Operator > is not defined for types system.collections.arraylist and system.collections.arraylist" so how am i supposed to see which date is newer, if i cant use < or >? or am i going about this all wrong?


View the full article
 
Back
Top