Ignore max length property on ADO.NET DataTable

458 views Asked by At

I create DataTable using the DataSet Tool in VB.NET. Now I'm facing the problem with maxlength property, which was auto generated when created.

Is there anyway to ignore this property? I kept getting .net exception for length violation. Or is there any other way to modify this property quick, I mean without open each table and modify for each column using the designer?

1

There are 1 answers

0
M463 On

As Zohar Peled stated: no you can't. If the datatype of your field equires you to set the maxlength, this is the applicable law for this field - no exceptions.

To save you the time of manual edit, you could fetch all tables from your DataSource with an SQL Query, loop through the tables and then, if a certain field exists within the given table, execute an ALTER TABLE command to edit the field-propertys.

Depending on the amount of affected tables, the open-db-and-do-it-by-hand-method might be faster and simpler.