G
Guest
Hello:
I defined a datatable with two columns:
dtTable = New DataTable("Names")
' Add three column objects to the table.
idColumn = New DataColumn()
idColumn.DataType = System.Type.GetType("System.String")
idColumn.ColumnName = "AER Number"
idColumn.MaxLength = 20
dtTable.Columns.Add(idColumn)
idColumn = New DataColumn()
idColumn.DataType = System.Type.GetType("System.String")
idColumn.ColumnName = "Case Version"
idColumn.MaxLength = 3
dtTable.Columns.Add(idColumn)
I am trying to insert rows into the table:
Dim row As DataRow
row = dtTable.NewRow()
row.BeginEdit()
row("AER Number") = "123"
row("Case Version") = "V3"
row.AcceptChanges
The last tow raises an error, "Cannot perform this operation on a row not in
the table."
And if I do not have this line, the row count remains at 0.
What am I doing wrong?
Venki
I defined a datatable with two columns:
dtTable = New DataTable("Names")
' Add three column objects to the table.
idColumn = New DataColumn()
idColumn.DataType = System.Type.GetType("System.String")
idColumn.ColumnName = "AER Number"
idColumn.MaxLength = 20
dtTable.Columns.Add(idColumn)
idColumn = New DataColumn()
idColumn.DataType = System.Type.GetType("System.String")
idColumn.ColumnName = "Case Version"
idColumn.MaxLength = 3
dtTable.Columns.Add(idColumn)
I am trying to insert rows into the table:
Dim row As DataRow
row = dtTable.NewRow()
row.BeginEdit()
row("AER Number") = "123"
row("Case Version") = "V3"
row.AcceptChanges
The last tow raises an error, "Cannot perform this operation on a row not in
the table."
And if I do not have this line, the row count remains at 0.
What am I doing wrong?
Venki