I have a databound textbox that is used to store a decimal value.
If my sql table stores this column as a decimal(2,2), then all of the numbers entered into the field will automatically put decimal places in that I don't want. For example, 45 becomes 45.00... 34.5 becomes 34.50.
If I set the sql table to nchar(10) and the dataset to system.string (max length of -1), then the number looks the way I would like it, however after a datatable update I end up with trailing whitespace after the number - filling up the rest of the unused 10 characters. For example, "45" becomes "45 " (8 spaces afterwards).
Does anybody know how I can fix this? I would prefer to store the numbers in SQL as a string (nchar(10))... but I don't know how to get rid of that darned whitespace. I would like to remove it at the database level and not at the client level if at all possible.
Thanks!
Using char means that you want to have fixed length attributes. using Varchar would use only the space that is needed for storing the attribute. You have to keep in mind that the insert behaviour is determined by your inserting application. if the application do insert "45 " then you have to manuipulate the application ratehr than the database. But normally you should only switch to a variable character length field, e.g. in this case VARCHAR(10).HTH, Jens Suessmeyer.http://www.sqlserver2005.de
No comments:
Post a Comment