>lnResult = SqlExec(lnBlDbHandle, 'Exec sp_UpdateBulkLoad @tiBedrijfId=' + > Transform(.piBedrijfId) + ",@tcLangUp='NL'")I see nothing wrong with the way that you're calling the stored procedure.
>Declare c_Bulkload Cursor Local For >Select r.LevensNr,d.iBlDierId,d.lDelete,d.pk_Dier,d.Naam,d.Roepnaam, >d.lBlMale,d.GeboorteDatum,d.DierSoort,d.Eigenaar,d.Vader,d.Moeder, >d.EtMoeder,s.pk_Source As iSource >From Dier d >Left Join Rund r On r.iBlDierId = d.iBlDierId >Left Join AvWSql.dbo.Source s On s.cApp = @tcSourceApp And s.cSource = d.cSource >Where d.pk_Bedrijf = @tiBedrijfIdThis cursor is SENSITIVE, meaning that any changes to the data by other connections will be reflected in the cursor.
>While @@Fetch_Status = 0You're only checking @@FETCH_STATUS for zero (0) which is a successful fetch of a row. Since the cursor is sensitive, you might want to check for a value of -2. A -2 will be returned in @@FETCH_STATUS when the two to be retrieved is no longer in the table.
> Select pk_Dieren > From AvWSql.dbo.Dieren > Where pk_Dieren = @pk_Dier > And fk_Bedrijf = @tiBedrijfId > > Select @liError = @@Error, @liRowCount = @@RowCount > If @liError = 0 And @liRowCount = 0I also notice that you have a SELECT query within the stored procedure. A stored procedure is capable of returning multiple result sets. I wonder if you're seeing ODBC trip on this. Put SET NOCOUNT ON at the top of the stored procedure. Also, the better practice would be to use IF EXISTS()
IF EXISTS (Select pk_Dieren From AvWSql.dbo.Dieren Where pk_Dieren = @pk_Dier And fk_Bedrijf = @tiBedrijfId)instead of running the query and checking @@ROWCOUNT. If you do need the number of rows, this is the perferred syntax:
IF (Select COUNT(pk_Dieren) From AvWSql.dbo.Dieren Where pk_Dieren = @pk_Dier And fk_Bedrijf = @tiBedrijfId) = the_valueI bet your problem will be fixed by putting SET NOCOUNT ON at the top of the stored procedure. Try that and let us know.