Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-12
8
Medium Priority
?
427 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 300 total points
ID: 12293275
Its a web app ?
Recompile :P
0
 
LVL 7

Accepted Solution

by:
ramesh12 earned 300 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 300 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Assisted Solution

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

Assisted Solution

by:etmendz
etmendz earned 300 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

604 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