Click here to Skip to main content
15,888,610 members
Home / Discussions / Database
   

Database

 
GeneralRe: string truncation Pin
_Damian S_9-Nov-11 15:56
professional_Damian S_9-Nov-11 15:56 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:08
sitebuilderLuc Pattyn9-Nov-11 16:08 
GeneralRe: string truncation Pin
jschell10-Nov-11 8:27
jschell10-Nov-11 8:27 
GeneralRe: string truncation Pin
Luc Pattyn10-Nov-11 9:47
sitebuilderLuc Pattyn10-Nov-11 9:47 
GeneralRe: string truncation Pin
PIEBALDconsult9-Nov-11 15:09
mvePIEBALDconsult9-Nov-11 15:09 
QuestionRe: string truncation Pin
Luc Pattyn9-Nov-11 15:15
sitebuilderLuc Pattyn9-Nov-11 15:15 
AnswerRe: string truncation Pin
PIEBALDconsult9-Nov-11 15:37
mvePIEBALDconsult9-Nov-11 15:37 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:02
sitebuilderLuc Pattyn9-Nov-11 16:02 
So far this is the best approach I have come up with (untested!):

1. I'll have my app interrogate the DB structures at startup to basically set up a
Dictionary<string tableName, Dictionary<string fieldName, int fieldLength>> stringMaxLenghts;

That isn't too much trouble, I already have a number of run-time checks for the presence of some tables and some fields (the database is going to exist in many generations).

2. For each relevant TextBox I'll have each of my dialog Load handlers call a static method:
StaticClass.SetTextBoxMaxLength(TextBox textbox, string tableName, string fieldName) {...}

which sets the TextBox.MaxLength property in accordance to the stringMaxLenghts information.
That will eventually cause some beeping at the very moment the user is typing too much text. Not that I like beeping a lot.

3.In the data layer, I'll have my DatabaseCommand.AddStringParameter(...) methods check the length of the string against stringMaxLenghts once more (and truncate if necessary); this to be safe in case some data slips through, e.g. something that doesn't come straight from a TextBox.

That seems a reasonable cost (only one Dict-of-Dicts being passed, plus a number of method calls in Load handlers) to accomplish most of what I want.

Comments are welcome. Better ideas too.

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: string truncation Pin
PIEBALDconsult9-Nov-11 16:08
mvePIEBALDconsult9-Nov-11 16:08 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:27
sitebuilderLuc Pattyn9-Nov-11 16:27 
GeneralRe: string truncation Pin
PIEBALDconsult9-Nov-11 16:56
mvePIEBALDconsult9-Nov-11 16:56 
GeneralRe: string truncation Pin
_Damian S_9-Nov-11 16:32
professional_Damian S_9-Nov-11 16:32 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 16:59
sitebuilderLuc Pattyn9-Nov-11 16:59 
GeneralRe: string truncation Pin
jschell10-Nov-11 8:21
jschell10-Nov-11 8:21 
GeneralRe: string truncation Pin
Luc Pattyn10-Nov-11 8:35
sitebuilderLuc Pattyn10-Nov-11 8:35 
AnswerRe: string truncation Pin
PIEBALDconsult9-Nov-11 15:28
mvePIEBALDconsult9-Nov-11 15:28 
AnswerRe: string truncation Pin
Wayne Gaylard9-Nov-11 17:09
professionalWayne Gaylard9-Nov-11 17:09 
AnswerRe: string truncation Pin
Luc Pattyn9-Nov-11 17:28
sitebuilderLuc Pattyn9-Nov-11 17:28 
GeneralRe: string truncation Pin
Wayne Gaylard9-Nov-11 17:42
professionalWayne Gaylard9-Nov-11 17:42 
GeneralRe: string truncation Pin
Luc Pattyn9-Nov-11 17:48
sitebuilderLuc Pattyn9-Nov-11 17:48 
GeneralRe: string truncation Pin
Mycroft Holmes13-Nov-11 6:13
professionalMycroft Holmes13-Nov-11 6:13 
GeneralRe: string truncation Pin
Luc Pattyn13-Nov-11 6:35
sitebuilderLuc Pattyn13-Nov-11 6:35 
QuestionTrying to get Pivot Table working in MS SQL 2005 Pin
VREntropy9-Nov-11 8:56
VREntropy9-Nov-11 8:56 
AnswerRe: Trying to get Pivot Table working in MS SQL 2005 Pin
Mycroft Holmes13-Nov-11 6:06
professionalMycroft Holmes13-Nov-11 6:06 
GeneralRe: Trying to get Pivot Table working in MS SQL 2005 Pin
VREntropy14-Nov-11 3:13
VREntropy14-Nov-11 3:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.