﻿<?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 » WinForms (How do I?)  » InvalidCastException... arggggggg</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Fri, 29 May 2026 13:03:39 GMT</lastBuildDate><ttl>20</ttl><item><title>InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23649.aspx</link><description>I'm getting total crazy now.&amp;nbsp; In my standard application framework I have made several Maintenance Dialogs - but suddenly on a new dialog I'm getting InvalidCastException on everything.....&amp;nbsp; It states the it is "Unable to cast of type 'System.DBNull' to type 'System.String'" on my primary key field.&lt;/P&gt;&lt;P&gt;The destination table and it happens everytime I click the NEW buttom!!!!!&lt;/P&gt;&lt;P&gt;What the he.. is going on...&amp;nbsp; Am I missing a flag or.....&lt;/P&gt;&lt;P&gt;Hope that some of you can come up with a way to get me back on track!&lt;/P&gt;&lt;P&gt;Regards&lt;BR&gt;Ulrik</description><pubDate>Sun, 28 Jun 2009 18:10:51 GMT</pubDate><dc:creator>Ulrik Mueller</dc:creator></item><item><title>RE: InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23703.aspx</link><description>Ulrik,&lt;/P&gt;&lt;P&gt;You are trying to do some very basic stuff, so as I mentioned in my previous post, it would help if I could see a sample so I know what you are doing.&amp;nbsp; An invalid cast exception can from from a lot of places.&amp;nbsp; The grid can play a role in this since you are binding...so my guess is that you have some logic somewhere within the grid or other event that is causing the issue.&amp;nbsp; Without seeing a reproduction it is going to be hard to give you any straight answers.</description><pubDate>Sun, 28 Jun 2009 18:10:51 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23702.aspx</link><description>It is working when there are data in the table.&lt;BR&gt;If the table is empty, I get the casting error when the BusinessBindingSource is on the WinForm.&lt;BR&gt;Amy ideas on how to suppres this error during creation of the firste record in a table????&lt;/P&gt;&lt;P&gt;/Ulrik</description><pubDate>Sun, 28 Jun 2009 18:00:05 GMT</pubDate><dc:creator>Ulrik Mueller</dc:creator></item><item><title>RE: InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23660.aspx</link><description>The only thing I can suggest at this point is for you to provide a sample reproducing the error.  There is something else within your code and I would like to see where the point of failure is.  Thanks.</description><pubDate>Wed, 24 Jun 2009 07:28:33 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23655.aspx</link><description>OK Trent, now I know what the problem is!&lt;/P&gt;&lt;P&gt;Normally everything is working, but when I add the BusinessBindingSource component to my winform and binds it the forms primary BO, it crashes with the InvalidCastException error.&lt;/P&gt;&lt;P&gt;Do you have any ideas on why this is happening ??&lt;/P&gt;&lt;P&gt;If I delete the BBS it is working like a dream!&amp;nbsp; The reason that I'm using this is because I need to include a DevExpress editbox for currency/numeric data entry!!&lt;/P&gt;&lt;P&gt;Regards&lt;BR&gt;Ulrik</description><pubDate>Tue, 23 Jun 2009 08:47:13 GMT</pubDate><dc:creator>Ulrik Mueller</dc:creator></item><item><title>RE: InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23654.aspx</link><description>Why why why ...&lt;/P&gt;&lt;P&gt;After I went to the BOM and changed the Field Properties on the PK field it seems to work without any exception.&lt;/P&gt;&lt;P&gt;I changed th "NULL Value Option" to "Return Alternate on Null" and let it set nospace "" in the replacement value!&lt;/P&gt;&lt;P&gt;I just don't know why I have this kind of problems with this specific BO!&lt;/P&gt;&lt;P&gt;/ULRIK</description><pubDate>Tue, 23 Jun 2009 08:20:41 GMT</pubDate><dc:creator>Ulrik Mueller</dc:creator></item><item><title>RE: InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23653.aspx</link><description>It is correct that the PrimaryKeyIsAutoincremented is set to FALSE - but I am setting the primary key field in the SETDEFAULTVALUE.&lt;/P&gt;&lt;P&gt;The PK field is a VarChar(5) - in other tables i'm using VC(10) in the same manner!!!&lt;/P&gt;&lt;P&gt;In the SetDefaultValues on the BO i'm making a &amp;gt;&amp;gt; this.pr_id = "ABC"; &amp;lt;&amp;lt;&lt;/P&gt;&lt;P&gt;I tried to run the application on a computer without VS2008 installed - it seems to work better - no crash at least!</description><pubDate>Tue, 23 Jun 2009 08:05:31 GMT</pubDate><dc:creator>Ulrik Mueller</dc:creator></item><item><title>RE: InvalidCastException... arggggggg</title><link>http://forum.strataframe.net/FindPost23652.aspx</link><description>Well, how do you have your primary key setup?  It sounds like you have the PrimaryKeyIsAutoIncrementing property set to false and then are not providing a PK in the SetDefaultValues.</description><pubDate>Tue, 23 Jun 2009 06:44:21 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>