Get error when try to set DataColumn variable again

  • Thread starter Thread starter Christopher Lusardi
  • Start date Start date
C

Christopher Lusardi

On the second call to the below method body, I get the error: A column
named 'Full Name' already belongs to this Data Table. In C++, what I
would do is either set col to null on exit from the method, or only do
the assignment if col is emply. Explicitly, how would I do these 2
things in VB?

Dim col As DataColumn

col = dsAdoSbs.Employees.Columns.Add("FullName",
System.Type.GetType("System.String"))

Thanks,
Christopher Lusardi
 
Christopher said:
On the second call to the below method body, I get the error: A column
named 'Full Name' already belongs to this Data Table. In C++, what I
would do is either set col to null on exit from the method, or only do
the assignment if col is emply. Explicitly, how would I do these 2
things in VB?

Dim col As DataColumn

col = dsAdoSbs.Employees.Columns.Add("FullName",
System.Type.GetType("System.String"))

Thanks,
Christopher Lusardi
Try deleting the column. Then you can add it again later.

T
 
Christopher,

There exist in Net the command "Add" and "Remove" column.

A pity is that you can save the column,

dim mycolumn as datatable.column = mydatatable.column(0)

but that does not contain the values in the items.

I hope this helps,

Cor
 
Back
Top