Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
| Search | Today's Posts | Mark Forums Read
.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
  #1 (permalink)  
Old February 12th, 2008, 03:53 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
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>
Code:
            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
                Else
                    EquentialCommand.Parameters.Item("@PlantId").Value = JobPrefixes(0)
                End If
            Else
                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")
            EquentialCommand.Parameters.Clear()
            EquentialConnection.Close()


[u]Stored Procedure:</u>
Code:
CREATE PROCEDURE sp_Vecellio_JobComparison
@PathFileName varchar(200),
@DateFrom datetime,
@DateTo datetime,
@PlantId char(3),
@JobNumber int
  #2 (permalink)  
Old February 12th, 2008, 04:03 PM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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

/- Sam Judson : Wrox Technical Editor -/
  #3 (permalink)  
Old February 12th, 2008, 04:46 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: West Palm Beach, Florida, USA.
Posts: 205
Thanks: 4
Thanked 0 Times in 0 Posts
Default

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.