Hi
Here is my code :
Code:
Dim dt As New DataTable
dt.Columns.Add.ColumnName = "New"
dt.Columns("New").DataType = System.Type.GetType("System.String")
dt.Columns.Add.ColumnName = "Id"
dt.Columns("Id").DataType = System.Type.GetType("System.Integer")
Dim Row As DataRow = dt.NewRow()
Dim rc As DataRowCollection = dt.Rows
rc.InsertAt(Row, 0)
Defining the ype of the column "New" doesn't crash the application but
defining the type of the column "Id" to integer raises the following
exception:
"System.ArgumentException: Cannot change DataType of a column once it
has data.
But there is no data in it since I've just created the column...
What's wrong with my code ??
Thx