Problemas con las transacciones

Problemas con las transaccione
23 de Junio del 2006

El erro que me presenta es el siguinte:
This SqlTransaction has completed; it is no longer usable.

Este es todo el código del procedimiento grabar, además utilizo tu función Ejecuta_comando



Dim Nsql As String

Dim HayError As String = ""

Dim tr As SqlTransaction

Dim J As Integer

If Cnn.State = ConnectionState.Open Then

Cnn.Close()

End If

Cnn.Open()

tr = Cnn.BeginTransaction()

Try

If Nuevo Then

Nsql = "Execute InsertRecibosTaller '" & Txtcodigoserie.Text & "','" & _

TxtRecibo.Text & "','" & _

CcDateIso(TxtFecha.Text) & "'," & _

Val(CFormat(TxtMonto.Text, 2)) & ",'" & _

CmbAplicar.Text & "'," & _

Val(CFormat(TxtMonto.Text, 2)) & ",'" & _

Txtcodigo.Text & "','" & _

CmbtipoPago.Text & "','" & _

TxtnoCheque.Text & "','" & _

TxtBanco.Text & "','" & _

TxtObservaciones.Text & "'"

Else

Nsql = "Execute UpdateRecibosTaller '" & Txtcodigoserie.Text & "','" & _

TxtRecibo.Text & "','" & _

CcDateIso(TxtFecha.Text) & "'," & _

Val(CFormat(TxtMonto.Text, 2)) & ",'" & _

CmbAplicar.Text & "'," & _

Val(CFormat(TxtMonto.Text, 2)) & ",'" & _

Txtcodigo.Text & "','" & _

CmbtipoPago.Text & "','" & _

TxtnoCheque.Text & "','" & _

TxtBanco.Text & "','" & _

TxtObservaciones.Text & "'"





End If

HayError = Ejecuta_Comando(Nsql, Nothing, Cnn, tr)

If HayError.Length > 0 Then

Throw New Exception("Error")

End If

Nsql = "Delete From DETALLE_RECIBOS_TALLER where SERIEFACTURA='" & Txtcodigoserie.Text & "' and NUMERORECIBO='" & TxtRecibo.Text & "'"



HayError = Ejecuta_Comando(Nsql, Nothing, Cnn, tr)

If HayError.Length > 0 Then

Throw New Exception("Error")

End If

For J = 0 To DsDetalle_Recibos.Tables(0).Rows.Count - 1

Nsql = "Execute insertDETALLERECIBOSTALLER '" & DsDetalle_Recibos.Tables(0).Rows(J).Item("CODIGOSERIE") & "','" & _

DsDetalle_Recibos.Tables(0).Rows(J).Item("NUMERORECIBO") & "','" & _

DsDetalle_Recibos.Tables(0).Rows(J).Item("NUMEROFACTURA") & "','" & _

CcDateIso(DsDetalle_Recibos.Tables(0).Rows(J).Item("FECHA")) & "'," & _

Val(CFormat(DsDetalle_Recibos.Tables(0).Rows(J).Item("VALOR"), 2)) & "," & _

Val(CFormat(DsDetalle_Recibos.Tables(0).Rows(J).Item("SALDO"), 2)) & ",'" & _

DsDetalle_Recibos.Tables(0).Rows(J).Item("ESTADO") & "'," & _

Val(CFormat(DsDetalle_Recibos.Tables(0).Rows(J).Item("DIFERENCIA"), 2)) & "," & _

Val(CFormat(DsDetalle_Recibos.Tables(0).Rows(J).Item("IMPORTE"), 2)) & "," & _

Val(CFormat(DsDetalle_Recibos.Tables(0).Rows(J).Item("NUEVOSALDO"), 2)) & ",'" & _

DsDetalle_Recibos.Tables(0).Rows(J).Item("SERIEFACTURA") & "'," & _

Val(CFormat(DsDetalle_Recibos.Tables(0).Rows(J).Item("TC"), 2)) & "," & _

Val(CFormat(DsDetalle_Recibos.Tables(0).Rows(J).Item("TCF"), 2)) & ""

HayError = Ejecuta_Comando(Nsql, Nothing, Cnn, tr)

If HayError.Length > 0 Then

Throw New Exception("Error")

End If



CancelarFactura(DsDetalle_Recibos.Tables(0).Rows(J).Item("NUMEROFACTURA"), DsDetalle_Recibos.Tables(0).Rows(J).Item("CODIGOSERIE"), tr) (el problema me da en este procedimiento cuando le paso la transaccion)



Next

tr.Commit()

Catch ex As Exception

tr.Rollback()

End Try



Si pongo en comentario el procedimiento CancelarFactura toda la transaccion me funciona bien , todo es que active el procedimiento y le pasa el valor de la transaccion me da error ,el problema que miro es cuando paso la transaccion ha un procedimiento, la transaccion toma el valor de Nothing . de antemano gracias por la ayuda que me brinden para resolver este problema, Estoy utilizando Vb.net 2005



Atentamente



Denis Guido