DBNULL...again


Author
Message
Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Scenario:

I have inherited a table with two fields, one decimal, one string. These together represent the primary key. I need both fields on a maintenance form, bound to textboxes.

Display/Edit/Save is working. I cannot get a new record to add.

I get 'Conversion from type 'DBNull' to type 'String' is not valid.' on the line:

Return CType(Me.CurrentRow.Item("ITREPORT"), System.String) in the field properties. I tried to set the defaultValues and the first one sets fine, the second always gives the above error, regardless of the order set. I have PrimaryKeyIsAutoIncremented = False, PrimaryKeyIsUpdateable = True, and even tried out AllowNullsOnNewRow = True. The database fields (DB2) are set to not allow nulls, and have default values set.

I know this could be fixed easily by adding a proper autoincrement key column but I cant, the table is part of a legacy system and the customer is insistant it work as described above, frankly I'm not sure why it isnt. It works fine if the fields are unbound from the textboxes.

I must be missing somethign simple. Which is likely since I havent been coding much lately.

 



Keith Chisarik
Replies
Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Makes sense Edhy, thanks.

Keith Chisarik
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I'll admit I am confused why that step was necessary, but I'll save that for another day, unless someone is feeling like enlightening

The solution will prevent the error, but is not the cause of the error.  You actually should not have to do this.  From what I understand, you are creating a new record.  At this point, the database type has no relavance as all of this is intrinsic to the BO.  So it would appear that when you are adding a record the fields are not being initialized...and/or you are referencing this field either through a manual binding, event, or some other code before it gets initialized.

By default, a BO has the AllowNullValuesONnewRow set to false, which forces all rows to be initialized with a default value when a new row is created.  So the NULL is not coming from there...it is happening in the Get of the strong-typed property which means that something is trying to call a GetValue before it is initialized.

You might check your mappings or place a breakpoint in the Get of the property to see what is pulling the value.  You have a "bandaid" on it so to speak and it would probably be a good idea to find the source of the issue.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Keith Chisarik - 17 Years Ago
Keith Chisarik - 17 Years Ago
Peter Jones - 17 Years Ago
Keith Chisarik - 17 Years Ago
Keith Chisarik - 17 Years Ago
Edhy Rijo - 17 Years Ago
Keith Chisarik - 17 Years Ago
Edhy Rijo - 17 Years Ago
Keith Chisarik - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Keith Chisarik - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Keith Chisarik - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Keith Chisarik - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Keith Chisarik - 17 Years Ago
Keith Chisarik - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Keith Chisarik - 17 Years Ago
             Cool :cool:
Trent L. Taylor - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search