Salve:

mi sta capitando che, usando l'AccessDataSource, non riesco ad impostare un try catch per verificare l'esattezza del salvataggio o dati.


Mi sapreste dire se c'è qualche paramtro booleano passato dal AccessDataSource per poter gestire un eventuale errore e quindi capire se lo storing dei dati è stato eseguito oppure no?

grazie mille!

gianluca
Intercetta gli eventi Inserted, Updated o Deleted e nell'argomento hai un Exception che è diverso da null se si è scatenata un eccezione. Guarda quello e se vuoi inibire il rilancio dell'eccezione imposta ExceptionHandled = true

Ciao

Il mio blog
Homepage
perdonami ma non riesco a capire come fare. Ti dispiacerebbe farmi un esempio pratico?

te ne sono grato
Così come ti ho spiegato, intercetti l'evento
<asp:AccessDataSource OnUpdated="datasource_Updated"

e nell'evento:
void datasource_Updated(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.Exception != null)
{
' c'è un errore

' inibisco l'errore
e.ExceptionHandled = true;
}
}

Modificato da Ricciolo il 13 aprile 2006 12.20 -

Ciao

Il mio blog
Homepage
ti ringrazio tantissimo, mi hai instradato!

anche se quello che mi hai detto non era corretto al 100% inserisco il codice che ho utilizzato per risolvere il mio problema sperando che possa servire a qualcun'altro:


PS: l'eccezione non va gestita dal AccessDataSource ma dal FormView visto che è il form che genera l'eccezione:


Sub EmployeeFormView_ItemInserted(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs)

' Use the Exception property to determine whether an exception
' occurred during the insert operation.
If e.Exception Is Nothing Then

' Use the AffectedRows property to determine whether the
' record was inserted. Sometimes an error might occur that
' does not raise an exception, but prevents the insert
' operation from completing.
If e.AffectedRows = 1 Then

MessageLabel.Text = "Record inserted successfully."

Else

MessageLabel.Text = "An error occurred during the insert operation."

' Use the KeepInInsertMode property to remain in insert mode
' when an error occurs during the insert operation.
e.KeepInInsertMode = True

End If

Else

' Insert the code to handle the exception.
MessageLabel.Text = e.Exception.Message

' Use the ExceptionHandled property to indicate that the
' exception has already been handled.
e.ExceptionHandled = True
e.KeepInInsertMode = True

End If

End Sub
Dipende dai punti vista e dalle esigenze, va bene sia sul controllo che sul datasource

Ciao

Il mio blog
Homepage
1.495 messaggi dal 27 dicembre 2005
scusate la domanda
come si installa l'AccessDataSource ??
E' già presente nell'assembly System.Web.
Scrivi:
<asp:AccessDataSource
che lui va

Ciao

Il mio blog
Homepage

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.