none
Setting maxlength of DataColumn in Datatable before filling the DataTable

    Question

  • I am getting the value from the database in and filling it to a Datatable using dataadapter's fill method, but when the data is filled to datatable boz the default size of the column is 255 the data get trimmed. There are some field in my database table which has column width more than 255 characters So please let me know how to set the maxlength of a datacolumn rather than having 255 as default width.

    Monday, September 29, 2008 11:51 AM

Answers

  • You should be able to get hold of the column and be able to set the size (before filling it).  Something like table.Columns["NameOfColumn"] should do it.  If you are using a strongly typed dataset, I dont think you have to do this as it is done for you by the designer.

     

     

    Monday, September 29, 2008 12:57 PM

All replies

  • You should be able to get hold of the column and be able to set the size (before filling it).  Something like table.Columns["NameOfColumn"] should do it.  If you are using a strongly typed dataset, I dont think you have to do this as it is done for you by the designer.

     

     

    Monday, September 29, 2008 12:57 PM
  • The DataTable should not ever "Trim" the data.   It may throw a ConstraintException, but it won't change the data.

    The property you were looking for was the DataColumn.MaxLength property.

     

    Monday, September 29, 2008 3:30 PM
    Moderator