Hi,

I'm writing a system that will interact with MQ and get message for different function from it. Message structure will be different for different function.

Each message consist of many records, e.g.:

C001John 20040510C002Peter 20030115

and what I need to do is to write a generic class, such that when I pass in the message definition and message itself, it will help to built the DataTable, and parse records from message to insert to the dt. Then, I can use Datagrid to display the DataTable.

At first, it seems logical to use Structure to define the "table", however, I found no way to define the size of each structure element. Later, I think of a solution, which is to define a "Field" structure first which will store the name, size and value.
Now, I can declare each structure element as "Field.

Structure Fld
size as integer
name as string
value as string
end structure

Structure Record
CustID as Fld
Name as Fld



But I soon run into another trouble on how to loop through each item in the structure

So, I think of using XML to define the schema, and then use a DataSet function to generate the DataTable directly. I have defined some simplyType in the XML schema, e.g.:

<xs:simpleType name="USERID">
<xs:restriction base="xs:string">
<xs:length value="3" />
</xs:restriction>
</xs:simpleType>

When I try to reference the MaxLength or corresponding column in the DataTable, it return -1 to me. What I need is the field length in order to get substring from the message to put it to the correct position.

Can someone suggest a proper way to handle this? I have no idea on how to implement it.

Thx a lot!