Quote:
Originally posted by stm
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.
Hi
VB Code:
' Create a DataTable.
Dim myTable As DataTable = new DataTable("myTable")
' Create a DataColumn and set various properties.
Dim myColumn As DataColumn = New DataColumn
myColumn.DataType = System.Type.GetType("System.Decimal")
myColumn.AllowDBNull = False
myColumn.Caption = "Price"
myColumn.ColumnName = "Price"
myColumn.DefaultValue = 25
' Add the column to the table.
myTable.Columns.Add(myColumn)
' Add 10 rows and set values.
Dim myRow As DataRow
Dim i As Integer
For i = 0 to 9
myRow = myTable.NewRow()
myRow("Price") = i + 1
' Be sure to add the new row to the DataRowCollection.
myTable.Rows.Add(myRow)
Next i