Solved

Running a stored procedure from VB.Net with parameters - expecting parameter

Posted on 2004-10-12
8
398 Views
Last Modified: 2012-08-14
I know that there is just a little thing missing, but I am unable to see it. Here is the error message that I receive:

Procedure 'sp_jrn_SelectDivStrategyIDByDivStrategyCode' expects parameter '@DivisionID' which was not supplied.

Original VB.Net code
'define a new data adapter
            Dim daStrategy As SqlClient.SqlDataAdapter

           'using the new data adapter locate in the database table tblDivStrategy any records with the same strategy code
            daStrategy = New SqlClient.SqlDataAdapter("sp_jrn_SelectDivStrategyIDByDivStrategyCode", conn)
            With daStrategy
                .SelectCommand.CommandType = CommandType.StoredProcedure
                .SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@DivStrategyCode", SqlDbType.Decimal))
                .SelectCommand.Parameters.Add(New SqlClient.SqlParameter("@DivisionID", SqlDbType.Int))
                .SelectCommand.Parameters("@DivStrategyCode").Value = txtStrategyCode.ClipText
                .SelectCommand.Parameters("@DivisionID").Value = drDivision("DivisionID")
            End With
           
            'fill the data set's (dsOther9) table Strategy with the data from the above select query
            daStrategy.Fill(dsOther9, "Strategy")

Stored procedure:
CREATE PROCEDURE [dbo].[sp_jrn_SelectDivStrategyIDByDivStrategyCode] (@DivStrategyCode Decimal, @DivisionID Integer)
AS
SELECT DivStrategyID
FROM vw_DivisionStrategyDetails
WHERE DivisionID = @DivisionID AND DivStrategy_Code = @DivStrategyCode
GO

Now, if I change the stored procedure to read as (only showing the WHERE line, no other changes)
         WHERE DivisionID = @DivisionID
it works as I expect it to work.

I have confirmed variable names, the variables contain data etc. I think I just need another set of eyes to look at my code, I do similar things in other places and it works.

Thanks Experts!!
0
Comment
Question by:MajikTara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 10

Assisted Solution

by:Hans Langer
Hans Langer earned 100 total points
ID: 12293275
Its a web app ?
Recompile :P
0
 
LVL 7

Accepted Solution

by:
ramesh12 earned 100 total points
ID: 12293507
check to make sure that you have values in here  drDivision("DivisionID")

i.e drDivision("DivisionID") is not null
0
 
LVL 14

Assisted Solution

by:ptakja
ptakja earned 100 total points
ID: 12294149
Since your DivStrategyCode is defined as a Decimal, try coverting the textbox "Text" to a Decimal. The issue could be that you are passing a "string" into the Decimal parameter.

   .SelectCommand.Parameters("@DivStrategyCode").Value = Convert.ToDecimal(txtStrategyCode.ClipText)
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 18

Assisted Solution

by:DotNetLover_Baan
DotNetLover_Baan earned 100 total points
ID: 12294461
How are you getting the value of "drDivision("DivisionID")" ?
-Baan
0
 
LVL 6

Assisted Solution

by:etmendz
etmendz earned 100 total points
ID: 12296568
You've checked the variables names... What about the field name DivStrategy_Code? Is that correct?

Have fun...
0
 

Author Comment

by:MajikTara
ID: 12298446
Gerente - No, this is not a web app. It is a windows app.

ramesh12 - I ran a messagebox that showed that the value drDivision("DivisionID") is a integer.

ptakja - Prior to changing the code to include the "@DivisionID" the code was only for "@DivStrategycode" and was working fine. I added the "@DivisionID" code for a different filter process in the SQL code.

DotNetLover Baan - the value of drDivision("DivisionID") is from a dataset (in memory) that is created then assigned to a datarow. The value of drDivision("DivisionID") is an integer.

etmendz - Yes, I reviewed all the variable names, even copied them from their source.

All - I believe it is just a syntax error that I am not seeing. Any other suggestions?
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12298674
I cant see errors in the systaxis.

Maybe the app is not compiling well,
Restart Windows, Restart  VS.NET, check Read-only files property,
Maybe something is blocked.
0
 

Author Comment

by:MajikTara
ID: 12299378
All -
It was a combination of your answers that helped me find the problem - I used the same stored procedure later but I did not update my VB code to reflect the change of adding the field "@DivisionID".  

Thanks All,

MT
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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