Problemas con ADDHANDLER
Publicado por Pedro Cornejo (3 intervenciones) el 09/11/2009 16:33:57
Al momento que se produce un error en el metodo FILL del dataadapter por ejm,por que un cursor de oracle no se inicializo(manejador de sentencias no ejecutado) no se reconoce el evento FILLERROR y no entra al prcedimiento asociado(DataAdapterOnFillError). Muchas Gracias
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim db As New BaseDatos
Try
db.Conectar()
db.CrearComando("aa", CommandType.StoredProcedure)
db.AsignarParametro("cur_unidad", OracleType.Cursor)
db.AsignarParametro("cur_err", OracleType.Cursor)
db.Desconectar()
Dim ds As DataSet = db.EjecutarDataSet
grid3.DataSource = ds.Tables(0).DefaultView
Catch ex As Excepcion
MessageBox.Show(ex.Excepcion)
End Try
End Sub
Public Function EjecutarDataSet() As DataSet
Try
Dim da As OracleDataAdapter = objFactory.CreateDataAdapter
da = New OracleDataAdapter
AddHandler da.FillError, AddressOf DataAdapterOnFillError
da = objFactory.CreateDataAdapter
Dim ds As DataSet = New DataSet
da.SelectCommand = ObjComando
Dim r As New DataSet
da.Fill(r)
'RemoveHandler da.FillError, AddressOf DataAdapterOnFillError
Me.ObjComando.Parameters.Clear()
Return ds
Catch ex As Exception
Throw New Excepcion("Error originado por EjecutarDataset", ex)
End Try
End Function
Public Sub DataAdapterOnFillError(ByVal sender As Object, ByVal e As System.Data.FillErrorEventArgs)
MsgBox("hola")
e.Continue = True
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim db As New BaseDatos
Try
db.Conectar()
db.CrearComando("aa", CommandType.StoredProcedure)
db.AsignarParametro("cur_unidad", OracleType.Cursor)
db.AsignarParametro("cur_err", OracleType.Cursor)
db.Desconectar()
Dim ds As DataSet = db.EjecutarDataSet
grid3.DataSource = ds.Tables(0).DefaultView
Catch ex As Excepcion
MessageBox.Show(ex.Excepcion)
End Try
End Sub
Public Function EjecutarDataSet() As DataSet
Try
Dim da As OracleDataAdapter = objFactory.CreateDataAdapter
da = New OracleDataAdapter
AddHandler da.FillError, AddressOf DataAdapterOnFillError
da = objFactory.CreateDataAdapter
Dim ds As DataSet = New DataSet
da.SelectCommand = ObjComando
Dim r As New DataSet
da.Fill(r)
'RemoveHandler da.FillError, AddressOf DataAdapterOnFillError
Me.ObjComando.Parameters.Clear()
Return ds
Catch ex As Exception
Throw New Excepcion("Error originado por EjecutarDataset", ex)
End Try
End Function
Public Sub DataAdapterOnFillError(ByVal sender As Object, ByVal e As System.Data.FillErrorEventArgs)
MsgBox("hola")
e.Continue = True
End Sub
Valora esta pregunta
0