Solved

Stored Procedure Expects Parameter

Posted on 2002-05-17
19
324 Views
Last Modified: 2010-05-02
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
Comment
Question by:Joe46
  • 6
  • 5
  • 3
  • +4
19 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7016226
can you post the stored procedures' header, and also the sample command line?
CHeers
0
 

Author Comment

by:Joe46
ID: 7016242
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
 
LVL 1

Expert Comment

by:ndb
ID: 7016253
Can you also give the content of the stored procedure?
0
 

Author Comment

by:Joe46
ID: 7016261
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7016275
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
 
LVL 4

Expert Comment

by:Steve Sirica
ID: 7016370
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
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7016373
SSirica:
the line "params1.Refresh" does all this automatically, at the cost of a network trip.
CHeers

0
 
LVL 4

Expert Comment

by:Steve Sirica
ID: 7016399
OK.  I noticed it was different than the code I was using, so I thought I'd give it a shot.

Steve
0
 

Author Comment

by:Joe46
ID: 7016433
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:Steve Sirica
ID: 7016455
Are they getting any errors?  Could this be as simple as ADO versions being out of synch?
0
 
LVL 5

Expert Comment

by:bob_online
ID: 7016578
Have you verified the store procedure at their location is the same?
0
 

Author Comment

by:Joe46
ID: 7016786
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
 
LVL 4

Expert Comment

by:Steve Sirica
ID: 7016794
Well it's just a thought.  Do any DB calls work or are just the ones with Parms broke?
0
 
LVL 5

Expert Comment

by:bob_online
ID: 7016870
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
 

Author Comment

by:Joe46
ID: 7016952
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
 

Author Comment

by:Joe46
ID: 7017112
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
 
LVL 4

Expert Comment

by:Steve Sirica
ID: 7017143
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7817810
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
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7909709
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now