J
J L
I have defined a structure
private structure FieldInfo
dim FieldName as string
dim OrdinalPostioin as Integer
dim DataType as Type
dim Size as Integer
end structure
I read this information from a DataReader which retrieves schema info
from an Access table. (That piece of information is for background
only, does not affect my question).
I fill an arraylist with FieldInfo objects.
I then add this arraylist to a HashTable whose key is the name of the
Access table and value is the arraylist of FieldInfo objects. The
hashtable is named TableFields
I am having trouble retrieving the information. Here is the code I am
using :
dim testField as FieldInfo
dim testFieldList as ArrayList
dim strTableName as String
for i = 0 to TableList.Count - 1
strTableName = TableList(i)
testFieldList.Clear()
testFieldList = TableFields.Item(strTableName)
dim m as integer
for m = 0 to testFieldList.Count - 1
testField = Ctype(testFieldList(m), FieldInfo)
messagebox.show( testField.FieldName & vbcrlf & _
testField.DataType.ToString & vbcrlf & _
testField.Size.ToString)
next
The problem is that this shows the field information for the second
table as belonging to the first and has no field information for the
second one.
Am I using the correct syntax to access an ArrayList of FieldInfo data
stored in a HashTable?
Is there a better way to go about it? The bottom line is that I want
to have a list of field name, ordinal position, data type and size for
each field in each data table so I can do some validation in my DAL in
a generic way once I know a table name.
TIA,
John
private structure FieldInfo
dim FieldName as string
dim OrdinalPostioin as Integer
dim DataType as Type
dim Size as Integer
end structure
I read this information from a DataReader which retrieves schema info
from an Access table. (That piece of information is for background
only, does not affect my question).
I fill an arraylist with FieldInfo objects.
I then add this arraylist to a HashTable whose key is the name of the
Access table and value is the arraylist of FieldInfo objects. The
hashtable is named TableFields
I am having trouble retrieving the information. Here is the code I am
using :
dim testField as FieldInfo
dim testFieldList as ArrayList
dim strTableName as String
for i = 0 to TableList.Count - 1
strTableName = TableList(i)
testFieldList.Clear()
testFieldList = TableFields.Item(strTableName)
dim m as integer
for m = 0 to testFieldList.Count - 1
testField = Ctype(testFieldList(m), FieldInfo)
messagebox.show( testField.FieldName & vbcrlf & _
testField.DataType.ToString & vbcrlf & _
testField.Size.ToString)
next
The problem is that this shows the field information for the second
table as belonging to the first and has no field information for the
second one.
Am I using the correct syntax to access an ArrayList of FieldInfo data
stored in a HashTable?
Is there a better way to go about it? The bottom line is that I want
to have a list of field name, ordinal position, data type and size for
each field in each data table so I can do some validation in my DAL in
a generic way once I know a table name.
TIA,
John