I created a stored procedure on SQL Server that works great. Now I can call it from VBA, but I want to return the value to find out if there were any errors, etc. The last parameter in my SP is configured as OUTPUT:
@DataSetID int = 0, @Destination char(1)='-', @errStatusOK bit OUTPUT
My VBA for calling SP is lower, but it will not work now, after adding a new parameter, and I'm not sure where I am wrong, I keep getting 3708 - Parameter object is improperly defined. Inconsistent or incomplete information was provided. 3708 - Parameter object is improperly defined. Inconsistent or incomplete information was provided. :
Set cnn = New adodb.Connection cnn.ConnectionString = "DRIVER=SQL Server;SERVER=SERVER\SERVER;DATABASE=a_db;Trusted_Connection=Yes" cnn.Open cnn.ConnectionString Set cmd = New adodb.Command cmd.ActiveConnection = cnn cmd.CommandType = adCmdStoredProc cmd.CommandText = "stprMoveDataSet" Set param = cmd.CreateParameter ("@DataSetID", adInteger, adParamInput, , stDataSet) cmd.Parameters.Append param Set param = cmd.CreateParameter ("@Destination", adChar, adParamInput, 1, stDestination) cmd.Parameters.Append param Set param = cmd.CreateParameter ("@errStatusOK", adBit, adParamReturnValue) cmd.Parameters.Append param rs.CursorType = adOpenStatic rs.CursorLocation = adUseClient rs.LockType = adLockOptimistic rs.Open cmd
How can I get vba to work with the OUTPUT parameter and make the return value “readable” by vba.
EDIT. I modified the question to be more precise about returning values, and not just about using OUTPUT parameters.
vba access-vba sql-server sql-server-2008 stored-procedures
aSystemOverload
source share