0
votes

I would like add new column to my datatable. The column is of type char with length of 10.

DataColumn d = new DataColumn(fieldname, typeof(char)); dt.Columns.Add(d);

My Question is how do I add "size" to this column?

Thanks a lot.

1

1 Answers

1
votes

Note that in C#, a char is always one character. Try this:

DataColumn d = new DataColumn(fieldname, typeof(string));
d.MaxLength = 10;
dt.Columns.Add(d);