declare @idPrestamo2 int, @idDocumento2 int Declare C_PRESTAMOS cursor for select idPrestamo,idDocumento from XSARCPrestamos where idPrestamo = @idPrestamo ---------------------------------------------------- Open C_PRESTAMOS FETCH C_PRESTAMOS into @idPrestamo2,@idDocumento2 WHILE @@FETCH_STATUS = 0 Begin --------------------------------------------------------------------- BEGIN TRANSACTION UPDATE XSARCPrestamos SET idEstadoPrestamo=@idNuevoEstado WHERE idPrestamo = @idPrestamo2 and idDocumento = @idDocumento2 -------------------------------------------------------------------- if @@error<>0 --error begin ROLLBACK TRAN RAISERROR('stp_xsarcprestamos_UPDATEIdEstado-Error al actualizar el Estado del prestamo.',14,1) RETURN 0 end else begin select @AffectedRows=@@ROWCOUNT COMMIT FETCH C_PRESTAMOS into @idPrestamo2,@idDocumento2 end End DEALLOCATE C_PRESTAMOS ... ...so, i am using the next c# code to run the storeprocedure...
//the number of affected rows. int affectedRows = -1; //execute the command making sure the connection gets closed in the end. try { //open the connecction of the command command.Connection.Open(); //execute the command and get the number of affected rows. affectedRows = command.ExecuteNonQuery(); } catch (Exception ex) {}but ever the affectedRows var return -1 and the records don't updated.....