Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 164229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:42:25+00:00 2026-05-11T11:42:25+00:00

At the one end of my web application I have a database table storing

  • 0

At the one end of my web application I have a database table storing a load of pieces of text.

In the middle I have an API that separates my application tiers.

At the other end I have a user interface consisting of many TextBoxes (or input type=text form elements, if you prefer).

I need the maxlength properties of the TextBoxes to be the same as the maximum string lengths in the various related database table columns. I would also like to do string length validation on my API.

Of course I can achieve this manually, but does anyone know of a technique on any platform that can assist in setting up any part of this automatically?

In my scenario I am using ASP.NET 3.5 WebForms, LINQ to SQL and SQL Server 2005.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:42:26+00:00Added an answer on May 11, 2026 at 11:42 am

    At risk of not answering the question at all…

    You seem to have a business rule that says ‘this particular field should contain a maximum of N characters.’

    I would argue that both the database column’s size and the textbox maximum length are separate consequences of this business rule. Fixing one from the other confuses correlation with causation.

    In addition, enforcing this business rule by examining the maximum length of the database column has other effects:

    • you’ll hit the database every time for what could otherwise be an in-memory validation operation;

    • if your business rule changes slightly (eg: N goes from 100 to 80 characters) then you need a schema-level change;

    • some databases working with variable-length character encoding like UTF8 only fuzzily define how many characters even fit in a given column;

    • more broadly, you’re coupling the business rule to an implementation artifact – what if you later decide to use an object database?

    I’m not suggesting that you don’t sensibly size your database columns (you should), only that you decouple the business rule from the database implementation. If you can get away with a simple fixed-length-check in the application code, I would suggest that.

    Edit having read your question a little more carefully, for your text field maximum lengths you need N ahead of validation. Nonetheless, this is still a business rule – can you write a MaximumLength attribute for your field accessors and interrogate that?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a prototype application (RESTful web service database front-end) that is written using
I really am feeling bad. I have one web application that sends Emails for
I have an application that consists of three parts: a front-end web shop for
We work on an internal corporate system that has a web front-end as one
I have a web application that I'll be distributing to customers. I'll give them
I am developing a web application where i have database backend with geo located
I have a decent working web application (Java/Servlet/Jsp) that I would like to improve
I have one application using MVC3 w/ Razor that has been working perfectly working
I have an web application that allows certain domain objects to be associated with
I'm creating a web application that serves as a front end to do SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.