﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Support for System.DBNull in bo.SetValue method</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 04 May 2026 21:14:18 GMT</lastBuildDate><ttl>20</ttl><item><title>Support for System.DBNull in bo.SetValue method</title><link>http://forum.strataframe.net/FindPost31985.aspx</link><description>Hi Trent, Ben,&lt;br/&gt;I am using more and more DevExpress controls and sometimes when hitting a DBNull value, the Business Object is not able to handle it, even though I have set the "NULL Value Option" in the BOM to "Return Alternante on Null = 0", but the SetValue(ByVal component As Object, ByVal value As Object) of the BO does not take System.DBNull into consideration.&lt;br/&gt;&lt;br/&gt;For example, this line below, will throw an exception if the value is System.DBNull&lt;br/&gt;&amp;nbsp;DirectCast(component, bizTransaction).FK_Vendor_Carrier = CType(value, System.Int32)&lt;br/&gt;&lt;br/&gt;But if I change the bo.Designer to something like this, it will work just fine, but the bo.Designer will be overwritten next time I use the BOM.&lt;br/&gt;&lt;span&gt;[code]&lt;br/&gt;&amp;nbsp;Case bizTransactionFieldNames.FK_Vendor_Carrier&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If value Is Nothing OrElse IsDBNull(value) Then&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectCast(component, bizTransaction).FK_Vendor_Carrier = 0&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DirectCast(component, bizTransaction).FK_Vendor_Carrier = CType(value, System.Int32)&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br/&gt;[/code]&lt;br/&gt;&lt;br/&gt;Is there a way to overcome this situation?&lt;br/&gt;&lt;/span&gt;</description><pubDate>Wed, 17 Apr 2013 23:28:48 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Support for System.DBNull in bo.SetValue method</title><link>http://forum.strataframe.net/FindPost31987.aspx</link><description>Hi Ben,&lt;br/&gt;&lt;br/&gt;Thanks for the fast response.&amp;nbsp; I forgot to mention, that this is a DevExpress control "DevExpress.XtraEditors.SearchLookUpEdit" which I included in the SF Inherited UI library.&lt;br/&gt;&lt;br/&gt;I posted the class in this thread &lt;a href="http://forum.strataframe.net/FindPost30273.aspx"&gt;&lt;a href="http://forum.strataframe.net/FindPost30273.aspx"&gt;http://forum.strataframe.net/FindPost30273.aspx&lt;/a&gt;&lt;/a&gt; I would appreciate if you can provide any vb code to get this done.</description><pubDate>Wed, 17 Apr 2013 23:28:48 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Support for System.DBNull in bo.SetValue method</title><link>http://forum.strataframe.net/FindPost31986.aspx</link><description>Yes, there are ways to prevent this. &amp;nbsp;The System.Windows.Forms.Binding class has a DataSourceNullValue property on it that allows you to specify the null value to put back into the data source when the control is null; it defaults to DBNull.Value. &amp;nbsp;So, you need to change this value for your binding in order for it to send back Nothing (or null, if you prefer) instead of DBNull.Value.&lt;br/&gt;&lt;br/&gt;&lt;div&gt;The bindings are created by SF through the BusinessLayer's AddBinding() method. &amp;nbsp;It's private, so you would need to change the source code and recompile if you want to change it there. &amp;nbsp;Simply add the line loBinding.DataSourceNullValue = Nothing where it's initializing the binding.&lt;br/&gt;&lt;br/&gt;&lt;div&gt;To avoid changing the source code, you would need to add a handler to your control's DataBindings.CollectionChanged event (the event is actually on the collection returned from the DataBindings property). &amp;nbsp;When that event fires, you can detect a new Binding and set its DataSourceNullValue to Nothing. &amp;nbsp;The BusinessLayer will push and pop data bindings from time to time, so you'll need to handle that event to configure each one properly; you can't do it just once. &amp;nbsp;You can also create a static method somewhere and add it as the handler to the controls as needed so you can program the logic in one place.</description><pubDate>Wed, 17 Apr 2013 22:07:20 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>