Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 331
  • Last Modified:

Stored Procedure Expects Parameter

My program works on my computer and another programmer's computer, but it fails at the clients site with the message "Procedure SpecialtyCheck expects parameter @Specialty which was not supplied."

I'm executing the stored procedure with a command and like I said it works on the computers in our office, but not on site.

The specialty comes from an Excel spreadsheet, but I received this from the client so I know we are reading the same data to import.

Thanks,
Joe
0
Joe46
Asked:
Joe46
  • 6
  • 5
  • 3
  • +4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you post the stored procedures' header, and also the sample command line?
CHeers
0
 
Joe46Author Commented:
Dim intResult As Integer     'Return value
Dim cmdCheck As ADODB.Command
Dim params1 As ADODB.Parameters
   
' Create connection and command objects
Set cmdCheck = New ADODB.Command
   
' Set command properties
Set cmdCheck.ActiveConnection = db
cmdCheck.CommandText = "SpecialtyCheck"
cmdCheck.CommandType = adCmdStoredProc
Set params1 = cmdCheck.Parameters

' Refresh parameters from database
params1.Refresh

' Specify input parameter values
'This value comes from the spreadsheet
params1("@Specialty") = cmdSpecialtyCode.Parameters("InSpecialtyDesc").Value

' Execute the command
cmdCheck.Execute , , adExecuteNoRecords

' Retrieve stored procedure return value
intResult = params1("RETURN_VALUE")


intResult will be a "1" if it is in the table and a "0" if it is not.
0
 
ndbCommented:
Can you also give the content of the stored procedure?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Joe46Author Commented:
This is the stored procedure.


CREATE PROCEDURE SpecialtyCheck
@Specialty varchar(100)
 AS
 
Begin
  If Exists(SELECT Specialty FROM SpecialtyCodes WHERE Specialty = @Specialty)
   Return 1
Else
  Return 0
End
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I think to remember that this could work:
params1("Specialty") = ...

or this should work anyway
params1(1) = ...
and
intResult = params1(0)


Furthermore, you could do this:
CREATE PROCEDURE SpecialtyCheck
@Specialty varchar(100) = NULL
AS ...

to ensure that even if no (empty) value is supplied the proc will be happy to execute...

CHeers



0
 
Steve SiricaSenior Web Application EngineerCommented:
I just checked some code of mine that uses commands and parameters and it doesn' look like you appending the parameter to the command object.  Here is a working snippet of code that I use:


dim adoPara          As ADODB.Parameter
dim adoComm          As ADODB.Command

adoComm.CommandType = adCmdStoredProc
adoComm.CommandText = strProc

Set adoPara = New ADODB.Parameter
adoPara.Name = "P1"
adoPara.Type = adVarChar
adoPara.Direction = adParamInput
adoPara.Size = Len("Some Value")
adoPara.Value = "some value"
adoComm.Parameters.Append adoPara

Hope that helps good luck
Steve
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
SSirica:
the line "params1.Refresh" does all this automatically, at the cost of a network trip.
CHeers

0
 
Steve SiricaSenior Web Application EngineerCommented:
OK.  I noticed it was different than the code I was using, so I thought I'd give it a shot.

Steve
0
 
Joe46Author Commented:
Since the code works on the computers in our office I was thinking they have something different on their end, but I have no idea what that could be.

Thanks,
Joe
0
 
Steve SiricaSenior Web Application EngineerCommented:
Are they getting any errors?  Could this be as simple as ADO versions being out of synch?
0
 
bob_onlineCommented:
Have you verified the store procedure at their location is the same?
0
 
Joe46Author Commented:
bob online,

I gave them the stored procedure and they did a copy and paste. Later I had them send me a screen shot of the code and it sure looks the same.

SSirica,

I will have to check to see what version of ADO they have on their computer.

Thanks,
Joe
0
 
Steve SiricaSenior Web Application EngineerCommented:
Well it's just a thought.  Do any DB calls work or are just the ones with Parms broke?
0
 
bob_onlineCommented:
Be careful when asking the client about the stored procedure.  So they did a copy and paste?  Did they compile it?  Where did they paste it?  In a source code file?  See my point?
0
 
Joe46Author Commented:
bob online,

The SP is in SQL Server 7. They have placed it in the correct place because I had them send me a screen shot of that too.

Thanks,
Joe
0
 
Joe46Author Commented:
SSirica,

I thought you might be on to something when they told me they are using ADO 2.5 and I'm using 2.6. But then the other computer in the office where it works is also using 2.5.

Oh well, thanks anyway.

Joe
0
 
Steve SiricaSenior Web Application EngineerCommented:
Well you still may not be out of the woods.  I don't think it's a 2.6 vs. a 2.6 issue.  I'm sure it will work fine using either.  What I was trying to get at was if the exe is compiled with a 2.6 ref and they are on 2.5 that could cause an ActiveX error.  I assume the other in house machine is developer machine and has a 2.5 ref set?  

See where I'm going?  That's why I asked if any DB calls worked at all.

Steve
0
 
DanRollinsCommented:
Hi Joe46,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

Joe46, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 6
  • 5
  • 3
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now