CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

(Changing) the length of a database text field and asp.net apps

The title suggest this should be a trivial matter. To get my user's satisfied I found some points to watch:

  • The amount of text the user can enter in a textbox on a webform is unlimited. The amount of space to store the text in the database is. To prevent the user typing in to much you set the MaxLength property of the textbox. By default this is 0, signifying no max.
  • When the columns type in the DB is set to char the content is padded with trailing spaces in the database. When the user tries to insert characters in a textbox where MaxLength has been set the trailing spaces will bump against the max and the input is stuck. The user first has to trim off the trailing spaces. VarChar columns don't suffer from this behavior.
  • When you change the length of of a text column you have to check all update and insertcommands of dataadapters working on the table. The column is in the parameter-lists and parameters have a length. You have to update those as well.

Peter


Published Nov 18 2004, 07:15 AM by pvanooijen
Filed under: ,

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!

This Blog

Syndication

News