Getting error when binding TextBox to field!


Author
Message
Ben Hayat
Ben Hayat
Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)Advanced StrataFrame User (946 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
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
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search