Solved

Stored Procedure Expects Parameter

Posted on 2002-05-17
19
322 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

759 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

23 Experts available now in Live!

Get 1:1 Help Now