NULL e DATASET

giovedì 12 gennaio 2006 - 12.03

hya77 Profilo | Newbie

CIAO!
HO UNA DATAGRID A CUI è ASSOCIATO UN DATASET ,
SE NON INSERISCO NULLA IN UN CAMPO DI TIPO NUMERICO O DATA, MI VA IN ERRORE!
******************************************************

Cast non valido dalla stringa "" al tipo 'Decimal'.
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 non valido dalla stringa "" al tipo 'Decimal'.

Source Error:
Line 177: r.AVA_PROG = CType(dgi.FindControl("TxtAVA_PROG"), TextBox).Text

******************************************************



COSA DEVO FARE?

:)

Brainkiller Profilo | Guru

>CIAO!
>HO UNA DATAGRID A CUI è ASSOCIATO UN DATASET ,
>SE NON INSERISCO NULLA IN UN CAMPO DI TIPO NUMERICO O DATA, MI
>VA IN ERRORE!
>******************************************************
>
>Cast non valido dalla stringa "" al tipo 'Decimal'.
>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.

Ciao,
devi gestire l'eccezione, prima di fare il CType devi verificare se è stato inserito qualcosa allora prosegui con il CType diversamente l'utente non ha inserito niente, o lo fermi o prosegui e inserisci nel database vuoto o null dipende da come l'hai disegnato e da che compotramento vuoi avere.

ciao

David De Giacomi
Microsoft MVP
http://blogs.dotnethell.it/david/

hya77 Profilo | Newbie

ho fatto
Try
r.AVA_PROG = CType(dgi.FindControl("TxtAVA_PROG"), TextBox).Text
Catch ex As Exception
r.AVA_PROG = vbNull

End Try

ma mette nel DB 1



HYA NON E' ROCK MA HARD ROCK!

hya77 Profilo | Newbie

AIUTATEMI PLEASE!

HYA NON E' ROCK MA HARD ROCK!

Brainkiller Profilo | Guru

>ho fatto
> Try
> r.AVA_PROG = CType(dgi.FindControl("TxtAVA_PROG"),
> TextBox).Text
> Catch ex As Exception
> r.AVA_PROG = vbNull
> End Try
>ma mette nel DB 1

Che vuol dire mette nel DB 1 ?
Dov'è la query di inserimento ?
Da dove arriva il valore Uno ?

ciao


David De Giacomi
Microsoft MVP
http://blogs.dotnethell.it/david/
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5