I have a SQL Server stored procedure that returns a varchar value to Access VBA, but I'm getting an error from Access saying it can't convert a varchar value to int. Nowhere is the return value specified as an integer, whether the procedure or in VBA. I've simplified the actual code for the sake of this post. The below is not the full code.
Stored procedure:
create procedure proc
@CreateOrUpdate varchar(6) output
as
begin
select @CreateOrUpdate = 'Create'
return @CreateOrUpdate
end
In Access VBA:
Dim Com As ADODB.Command
Set Com = New ADODB.Command
With Com
.ActiveConnection = Cnn (Set elsewhere - No problems with this)
.CommandType = adCmdStoredProc
.CommandText = "proc"
.Parameters.Append .CreateParameter("@CreateOrUpdate", adVarChar, adParamOutput, 6)
End With
Result: "Conversion failed when converting the varchar value 'Create' to data type int."
I have other return values that are also varchar with identical syntax and I'm not having any problems with them. Any help is appreciated.
int; and then you have other problems.NULLvalues and empty strings/whitespace -- these will end up as 0). You should definitely remove these if they're used inRETURNstatements. You can have any number ofVARCHARoutput parameters, though.