AYuda pls...

19/07/2004 - 19:05 por CRISTHIAN MASSA MEDINA | Informe spam
Amigos
tengo este error, me pueden ayudar para hacer esta conversión!!!

Gracias
Cast from type 'DBNull' to type 'String' is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Cast from type 'DBNull' to
type 'String' is not valid.

Source Error:
 

Leer las respuestas

#1 Gustavo The Wolf Cantero
19/07/2004 - 20:28 | Informe spam
Este error te da porque el campo que querés leer es nulo. Antes de leerlo tendrias que compararlo con System.DBNull.Value para fijarte si no es nulo.
Por ejemplo:

C#
string Valor = DataReader["campo"] == System.DBNull.Value ? "" : objDR["maxHora"];

VB.NET

Dim Valor As String = Iif(DataReader["campo"] = System.DBNull.Value, "", objDR["maxHora"])

Espero que te sirva.
Suerte!
Gustavo A. Cantero
Microsoft Certified Solution Developer
DCE Tercera Estrella


"CRISTHIAN MASSA MEDINA" wrote:

Amigos
tengo este error, me pueden ayudar para hacer esta conversión!!!

Gracias
Cast from type 'DBNull' to type 'String' is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Cast from type 'DBNull' to
type 'String' is not valid.

Source Error:



Preguntas similares