Unable to cast object of type 'System.DBNull' to type 'System.String'.


Unable to cast object of type 'System.DBNull' to type 'System.String'....
Author
Message
Luiz Carneiro Lima
Luiz Carneiro Lima
StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)
Group: Forum Members
Posts: 25, Visits: 87
Olá,

Configurei o meu projeto no Business Object Mapper mas quando mando executar aparece a mensagem de erro que segue em anexo...

No Custom Wizard eu configurei pra quando for null string passa a ser "" e int passa a ser 0... Mas continua dando o erro...

Podem me ajudar?

Fico no aguardo.

Abraços

Angela

Attachments
ProblemaNull.jpg (172 views, 205.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You need to open the BO Mapper and set the NULL support that you want to provide for the field.  You can use the Customization Wizard to apply NULL support to a wide array of fields at the same time.  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.  The most common when dealing with a string is to return an alternate value and then to provide an empty string.

To get to this screen:

  1. Click StrataFrame -> Business Object Mapper
  2. Select your BO on the left
  3. Select the field on the right panel
  4. Click the Customize button

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.  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.

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Entendeu Angela?
Luiz Carneiro Lima
Luiz Carneiro Lima
StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)
Group: Forum Members
Posts: 25, Visits: 87
Entendi sim e fiz o que foi passado, passou por aquela parte, mas deu outro erro...

Tá em anexo...

Abraços

Attachments
ProblemaNull01.jpg (156 views, 145.00 KB)
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Não é o mesmo caso, mas para outro campo?
Luiz Carneiro Lima
Luiz Carneiro Lima
StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)
Group: Forum Members
Posts: 25, Visits: 87
Eu fiz isso que foi passando tanto para os campos string quanto int...

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...

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
No caso dos campos int , você precisa setar para (reference type). E então pode inserir 0 como Replacement Value.


Luiz Carneiro Lima
Luiz Carneiro Lima
StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)
Group: Forum Members
Posts: 25, Visits: 87
Fiz a mudança para reference type e continua apresentando o mesmo problema de cast...
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Foi feito também "Build Partial"?


Luiz Carneiro Lima
Luiz Carneiro Lima
StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)StrataFrame Beginner (25 reputation)
Group: Forum Members
Posts: 25, Visits: 87
Foi feito sim...
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