Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 12th, 2008, 03:53 PM
Friend of Wrox
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default [Resolved] Error calling a sp - parameter error

I am calling a stored procedure and get parameter error. I do not see where the problem is. Error is:

System.Data.SqlClient.SqlException: Procedure 'sp_Vecellio_JobComparison' expects parameter '@PlantId', which was not supplied

[u]VB Code:</u>
            EquentialCommand.Parameters.Add(New SqlClient.SqlParameter("@PathFileName", SqlDbType.Char)).Value = AbsolutePath
            EquentialCommand.Parameters.Add(New SqlClient.SqlParameter("@DateFrom", SqlDbType.DateTime)).Value = DateTimePicker1.Text
            EquentialCommand.Parameters.Add(New SqlClient.SqlParameter("@DateTo", SqlDbType.DateTime)).Value = DateTimePicker2.Text
            EquentialCommand.Parameters.Add(New SqlClient.SqlParameter("@PlantId", SqlDbType.Char)).Value = ComboBox1.SelectedItem
            EquentialCommand.Parameters.Add(New SqlClient.SqlParameter("@JobNumber", SqlDbType.Int)).Value = CInt(TextBox1.Text)
            If ComboBox1.SelectedItem <> Nothing Then
                If ComboBox1.SelectedItem = "All Plants" Then
                    EquentialCommand.Parameters.Item("@PlantId").Value = ComboBox1.SelectedItem
                    EquentialCommand.Parameters.Item("@PlantId").Value = JobPrefixes(0)
                End If
                If TextBox1.Text <> Nothing Then
                    EquentialCommand.Parameters.Item("@JobNumber").Value = TextBox1.Text
                End If
            End If
            EquentialCommand.CommandType = CommandType.StoredProcedure
            EquentialCommand.CommandText = ("sp_Vecellio_JobComparison")
            EquentialCommand.Connection = EquentialConnection
            mySqlDataAdapter.SelectCommand = EquentialCommand
            mySqlDataAdapter.Fill(mySqlDataSet, "JobListTable")

[u]Stored Procedure:</u>
CREATE PROCEDURE sp_Vecellio_JobComparison
@PathFileName varchar(200),
@DateFrom datetime,
@DateTo datetime,
@PlantId char(3),
@JobNumber int
Old February 12th, 2008, 04:03 PM
samjudson's Avatar
Friend of Wrox
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

You'll probably find that ComboBox1.SelectedItem is null.

/- Sam Judson : Wrox Technical Editor -/
Old February 12th, 2008, 04:46 PM
Friend of Wrox
Join Date: Mar 2007
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts

Good catch.... is now working....

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Resolved] Error: File used by another process snufse .NET Framework 2.0 2 February 18th, 2008 09:20 AM
(Resolved) TableAdapter Error ksamuel Pro Visual Basic 2005 1 January 16th, 2008 01:03 PM
chapter 2, error uri cannot be resolved in either boylevel BOOK: Beginning JavaServer Pages 2 November 21st, 2007 12:54 PM
SP - executing error filipczako SQL Language 3 December 12th, 2005 10:50 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.