for me it's essential to know this behaviour:
' Access Developer Handbook Vol. 2 S. 265:
' 1.
' If you use the SET NOCOUNT ON statement within a SQL Server StoredProc,
' RecordsAffected will be set to -1 if the procedure succeeded and 0 if it did not
'
' 2.
' Under certain conditions, RecordsAffected can report a spurious number. This might happen, for example,
' if the query or stored procedure causes a trigger to be executed or a stored procedure includes multiple SQL statements!!!
The solution is to use OUTPUT parameter(s):
in the SP:
, @ParOUT_RowsINSERTEDAS int OUTPUT
.
.
EXECUTE @ParOUT_RowsINSERTED = dbo.sp2_INSERT 0
, @ParPRINTER_NAME
, NULL
, @ParDSServer
, @ParDSDatenbank
, @ParDSTabelle
in VBA add these lines:
Set prm = cmd.CreateParameter("NumberRowsINSERTED", adInteger, adParamOutput)
cmd.Parameters.Append prm
cmd.Execute RecordsAffected:=lngReturnRowsAffected, Options:=adExecuteNoRecords
' Attention:
' as the StoredProc uses multiple SQL statements, the value of lngReturnRowsAffected is -1 (SP succeeded)
' => so use the OUTPUT parameter!
'fctINS = lngReturnRowsAffected
fctINS = cmd.Parameters("NumberRowsINSERTED")
I'm still learning...:cool:
--
candide
________Panta rhei