base.SetNewFieldValue

Posts   
 
    
Matiur
User
Posts: 10
Joined: 29-Nov-2005
# Posted on: 24-May-2006 20:43:40   

I am trying to assign a field value, but it is not allowing to assign as its length is more than what is in the Database.

I was debugging my code and found that it is calling base class's **base.SetNewFieldValue ** where it is checking for valid value.

My question is how does the base class know what the Database field length is? Is it calling the database again or it stores some where else?

I may need to rebuild the code again to sync with the database.

Thanks,

Matiur Rahman

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 25-May-2006 02:33:04   

SetNewFieldValue will call ValidateValue. This method will check the length or the size of the field depending on the type. Here is the code that is executed for strings to check the length of the value. You will need to regenerate your code to have a larger value if you have changed it in your database.

if(fieldToValidate.DataType == typeof(System.String))
                    {
                        // check length
                        string valueAsString = (string)value;
                        wasSuccesful = ((valueAsString.Length >= 0) && (valueAsString.Length <= fieldToValidate.SourceColumnMaxLength));
                        exceptionMessage = "The value specified will cause an overflow error in the database. Value length: " + valueAsString.Length +". Column max. length: " + fieldToValidate.SourceColumnMaxLength;
                    }