Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using a StoreProcedure to update multiple records.
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01469120
Message ID:
01469173
Vues:
40
>Hello friends!
>
>i am using a store procedure to update multiple records using the next SP code :
>this is because i am lock masive updates via the trigger update...
>
>
>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.....
>
>i run the SP in the serve and work fine....whats is grong?, any help is grear appreciated...

Can you post the code that creates and sets up command?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform