I have a simple table (Zip codes) which has three fields
ZipCode => String(7)
State => String(2)
City => String(20)
My primary key is set to ZipCode field.
I created a maintenance form, placed a copy of ZipCodeBO on the form, placed a "BusineddBindngSource" attached to ZipCodeBO. Placed DataGrid and connected it to BBS.
I then placed three TextBoxes on the form and connected the them to each field of the table.
When I run the form and press "New" button, I get the following runtime error.
Message="Unable to cast object of type 'System.DBNull' to type 'System.String'."
Source="BO"
StackTrace:
at Playkids.PDS.BO.ZipCodeBO.get_ZipCode() in C:\PDS\Program\BO\ZipCodeBO.Designer.cs:line 283
at Playkids.PDS.BO.ZipCodeBO.Field_ZipCode_Descriptor.GetValue(Object component) in C:\PDS\Program\BO\ZipCodeBO.Designer.cs:line 485
at System.Windows.Forms.BindToObject.GetValue()
at System.Windows.Forms.Binding.PushData(Boolean force)
VS points me to the "Get" section of my ZipCode property.
If I remove the textbox or disconnect the binding, then it works fine.
I checked the DDT and database, and none the field is checked as "AllowNull".
Thanks!
..ßen