﻿<?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?)  » Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 10:26:31 GMT</lastBuildDate><ttl>20</ttl><item><title>Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10412.aspx</link><description>Olá,&lt;/P&gt;&lt;P&gt;Configurei o meu projeto no Business Object Mapper mas quando mando executar aparece a mensagem de erro que segue em anexo...&lt;/P&gt;&lt;P&gt;No Custom Wizard eu configurei pra quando for null string passa a ser "" e int passa a ser 0... Mas continua dando o erro...&lt;/P&gt;&lt;P&gt;Podem me ajudar?&lt;/P&gt;&lt;P&gt;Fico no aguardo.&lt;/P&gt;&lt;P&gt;Abraços&lt;/P&gt;&lt;P&gt;Angela</description><pubDate>Thu, 16 Aug 2007 09:48:45 GMT</pubDate><dc:creator>Luiz Carneiro Lima</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10893.aspx</link><description>Good you got it!&lt;/P&gt;&lt;P&gt;;)</description><pubDate>Thu, 16 Aug 2007 09:48:45 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10892.aspx</link><description>The value was decimal… therefore was giving problem of cast. &lt;/P&gt;&lt;P&gt;I corrected the problem.&lt;/P&gt;&lt;P&gt;Thanks!!</description><pubDate>Thu, 16 Aug 2007 09:22:13 GMT</pubDate><dc:creator>Luiz Carneiro Lima</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10885.aspx</link><description>If you put a breakpoint on the line where it fails, add the loValue.GetType() to the watch window to see what the type actually is.&amp;nbsp; It is indicating that the type cannot be casted, so we need to know what is in loValue.&amp;nbsp; I know the display value is "1" but I would like to know what the GetType() method indicates the data type as.</description><pubDate>Wed, 15 Aug 2007 15:43:49 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10876.aspx</link><description>Boa tarde Ivan,&lt;/P&gt;&lt;P&gt;Continuo com o problema de cast&amp;nbsp;ao usar o StrataFrame...&lt;/P&gt;&lt;P&gt;Seguindo o tutorial consegui criar uma tela e listar alguns registros do banco de dados; mas quando mando incluir dá um erro de Cast.. Ele tenta converter 1 para inteiro...&lt;/P&gt;&lt;P&gt;Segue em anexo uma imagem do erro. Isso acontece quando o campo perde o foco.&lt;/P&gt;&lt;P&gt;Olhei na pasta de log mas não tem nenhum arquivo criado com a data de hoje...&lt;/P&gt;&lt;P&gt;Fico no aguardo de um contato.&lt;/P&gt;&lt;P&gt;Obrigada.&lt;/P&gt;&lt;P&gt;Angela</description><pubDate>Wed, 15 Aug 2007 13:58:56 GMT</pubDate><dc:creator>Luiz Carneiro Lima</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10456.aspx</link><description>Angela, desculpa, aonde você lê "aelu Type", deveria ser "Value Type"&lt;/P&gt;&lt;P&gt;Nem digitar eu sei direito... :D</description><pubDate>Thu, 19 Jul 2007 11:33:30 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10451.aspx</link><description>[quote][b]Ben Chase (07/19/2007)[/b][hr]The first problem looks fixed, but the second problem (the Int32 one) looks like the "loValue" is not really an integer.&amp;nbsp; I'm thinking she'll just have to place the loValue in the watch window so we can check what type it is.[/quote]&lt;/P&gt;&lt;P&gt;Thanks Ben.&lt;/P&gt;&lt;P&gt;Angela, por favor, primeiro gostaria que você voltasse no BO Mapper e configurasse seu campo int de volta para "aelu Type"... desculpa... :blush:&amp;nbsp; Depois que fizer isto, faça o Build Partial, Rebuild sua aplicação e veja se o erro continua.&lt;/P&gt;&lt;P&gt;Se continuar, o Ben está pedindo para você colocar o loValue na Watch Window para a gente descobrir que "type"&amp;nbsp; ele está setado no momento do erro. Se você pudesse mandar a "Stack Trace" para a gente ver também, ajudaria bastante.</description><pubDate>Thu, 19 Jul 2007 10:49:41 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10447.aspx</link><description>The first problem looks fixed, but the second problem (the Int32 one) looks like the "loValue" is not really an integer.&amp;nbsp; I'm thinking she'll just have to place the loValue in the watch window so we can check what type it is.</description><pubDate>Thu, 19 Jul 2007 09:13:41 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10431.aspx</link><description>Foi feito sim...</description><pubDate>Wed, 18 Jul 2007 14:55:14 GMT</pubDate><dc:creator>Luiz Carneiro Lima</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10430.aspx</link><description>Foi feito também "Build Partial"?&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://forum.strataframe.net/Uploads/Images/8b36cb5c-b4a4-4075-99d0-6ceb.png"&gt;</description><pubDate>Wed, 18 Jul 2007 14:53:07 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10429.aspx</link><description>Fiz a mudança para reference type e continua apresentando o mesmo problema de cast...</description><pubDate>Wed, 18 Jul 2007 14:48:53 GMT</pubDate><dc:creator>Luiz Carneiro Lima</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10428.aspx</link><description>No caso dos campos int , você precisa setar para (reference type). E então pode inserir 0 como Replacement Value.&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://forum.strataframe.net/Uploads/Images/c31d5d93-7864-4ed4-8167-2a00.png"&gt;</description><pubDate>Wed, 18 Jul 2007 14:38:23 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10421.aspx</link><description>Eu fiz isso que foi passando tanto para os campos string quanto int...&lt;/P&gt;&lt;P&gt;No primeiro caso tava dando erro de conversão porque o campo estava vindo com valor null... Neste caso tá falando que a conversão é inválida mas essa variável loValue tem o valor 1... não tá vindo como null...</description><pubDate>Wed, 18 Jul 2007 14:19:06 GMT</pubDate><dc:creator>Luiz Carneiro Lima</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10419.aspx</link><description>Não é o mesmo caso, mas para outro campo?</description><pubDate>Wed, 18 Jul 2007 14:10:15 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10418.aspx</link><description>Entendi sim e fiz o que foi passado, passou por aquela parte, mas deu outro erro...&lt;/P&gt;&lt;P&gt;Tá em anexo...&lt;/P&gt;&lt;P&gt;Abraços</description><pubDate>Wed, 18 Jul 2007 13:56:45 GMT</pubDate><dc:creator>Luiz Carneiro Lima</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10416.aspx</link><description>Entendeu Angela?</description><pubDate>Wed, 18 Jul 2007 13:14:32 GMT</pubDate><dc:creator>Ivan George Borges</dc:creator></item><item><title>RE: Unable to cast object of type 'System.DBNull' to type 'System.String'.</title><link>http://forum.strataframe.net/FindPost10414.aspx</link><description>You need to open the BO Mapper and set the NULL support that you want to provide for the field.&amp;nbsp; You can use the Customization Wizard to apply NULL support to a wide array of fields at the same time.&amp;nbsp; But in short, you need to indicate how you intend to deal with NULLs at the field level of the BO so that the binding and BO can manage it.&amp;nbsp; The most common when dealing with a string is to return an alternate value and then to provide an empty string.&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://forum.strataframe.net/Uploads/Images/d8472696-874d-4016-b45c-a139.png"&gt;&lt;/P&gt;&lt;P&gt;To get to this screen:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Click StrataFrame -&amp;gt; Business Object Mapper&lt;/LI&gt;&lt;LI&gt;Select your BO on the left&lt;/LI&gt;&lt;LI&gt;Select the field on the right panel&lt;/LI&gt;&lt;LI&gt;Click the Customize button&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The option specified above will covert a NULL value in the database into an empty string and an empty string will be saved back to the database as NULL.&amp;nbsp; If you do not want the value to be set back to the server as NULL then just choose the Return Alternate on Null option.</description><pubDate>Wed, 18 Jul 2007 13:07:14 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>