Peter's Gekko

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
(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


Posted 11-18-2004 7:15 AM by pvanooijen
Filed under: ,

[Advertisement]

Comments

JosephCooney wrote re: (Changing) the length of a database text field and asp.net apps
on 11-18-2004 5:25 AM
Regarding your first point: I seem to remember reading somewhere that the maximum amount of text that can be entered via a web browser text area is 32K or 65K. I can't remember where I read this, so it might not be correct.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?