#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Procedure or function expects parameter


    Hi, need help.
    i have a program, where i was not unable to update anything from selected data, because this error appears " Procedure or function 'SP_Assigned_Vehicle_Update' expects parameter '@Pilot_ID', which was not supplied."


    Here is my code in sql 2008 stored procedured "SP_Assigned_Vehicle_Update"

    USE [PILOT_SCHEDULE]
    GO
    /****** Object: StoredProcedure [dbo].[SP_Assigned_Vehicle_Update] Script Date: 09/13/2012 09:02:56 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[SP_Assigned_Vehicle_Update]

    @Assign_Vehicle_ID int output,
    @Pilot_ID bigint,
    @Schedule_No int,
    @Plate_No nvarchar(10),
    @Description nvarchar(150),
    @Transaction_Date smalldatetime,
    @Destination nvarchar(50),
    @Departure_Time smalldatetime,
    @Arrival_Time smalldatetime,
    @Cancel bit,
    @Cancel_By nvarchar(50)

    AS
    begin

    SET @Transaction_Date = GETDATE() -- To set ModifiedDate from datetime

    UPDATE Assigned_Vehicle

    SET

    Pilot_ID=@Pilot_ID,
    Schedule_No = @Schedule_No,
    Plate_No = @Plate_No,
    Description = @Description,
    Transaction_Date = @Transaction_Date,
    Destination = @Destination,
    Departure_Time = @Departure_Time,
    Arrival_Time = @Arrival_Time,
    Cancel = @Cancel,
    Cancel_By = @Cancel_By

    WHERE Assign_Vehicle_ID = @Assign_Vehicle_ID

    --SELECT * FROM Assigned_Vehicle --For Check if the added

    END




    and here is my code under visual basic 2010

    Private Sub assigned_vehicle_update()
    Dim cmd As SqlClient.SqlCommand
    Try
    cmd = New SqlClient.SqlCommand
    With cmd
    .Connection = Globals.Connection
    .CommandType = CommandType.StoredProcedure
    .CommandText = "SP_Assigned_Vehicle_Update"
    'from database itself
    .Parameters.Add("@Assign_Vehicle_ID", SqlDbType.Int)
    .Parameters.Add("@Pilot_ID", SqlDbType.BigInt)
    .Parameters.Add("@Schedule_No", SqlDbType.Int)
    .Parameters.Add("@Plate_No", SqlDbType.NVarChar, 10)
    .Parameters.Add("@Description", SqlDbType.NVarChar, 50)
    .Parameters.Add("@Transaction_Date", SqlDbType.SmallDateTime)
    .Parameters.Add("@Destination", SqlDbType.NVarChar, 150)
    .Parameters.Add("@Departure_Time", SqlDbType.SmallDateTime)
    .Parameters.Add("@Arrival_Time", SqlDbType.SmallDateTime)
    .Parameters.Add("@Cancel", SqlDbType.Bit)
    .Parameters.Add("@Cancel_By", SqlDbType.NVarChar, 50)
    'for windows gui
    .Parameters("@Assign_Vehicle_ID").Value = Assign_Vehicle_ID
    .Parameters("@Pilot_ID").Value = Me.cboPilotName.SelectedValue
    .Parameters("@Schedule_No").Value = Me.cboScheduleNo.SelectedValue
    .Parameters("@Plate_No").Value = Me.cboPlateNo.SelectedValue
    .Parameters("@Description").Value = Me.cboDescription.SelectedValue
    .Parameters("@Transaction_Date").Value = Me.dtpTransactionDate.Value.ToShortDateString
    .Parameters("@Destination").Value = Me.cboDestination.Text.Trim
    .Parameters("@Departure_Time").Value = Me.dtpDepartureTime.Value.ToShortTimeString
    .Parameters("@Arrival_Time").Value = Me.dtpArrivalTime.Value.ToShortTimeString
    .Parameters("@Cancel").Value = Me.chkCancel.Checked
    .Parameters("@Cancel_By").Value = Me.txtCancelBy.Text.Trim

    .ExecuteNonQuery()

    End With

    Catch ex As Exception
    'Throw ex
    MsgBox(ex.Message)
    End Try
    End Sub


    I hope u can help me guys regarding this error. Thank you very much.
    Highly appreciated if u can help me with this one..

    thanks.
  2. #2
  3. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    I would check that Me.cboPilotName.SelectedValue returns something , and that this something is an integer.

    You may also need to explicitly cast SelectedValue to an integer.

    Comments on this post

    • medialint agrees
    Last edited by AndrewSW; September 13th, 2012 at 07:50 PM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0
    thanks buddy, i have already the solutions, and i want to share:
    here is the solution i made.

    in my sql database, i called a view, and one of my codes i have concatenation and here is the code
    SELECT Pilot_ID, Emp_No, Pilot_Name, Include, Pilot_Name + ' ' + Emp_No AS Pilot_Names
    FROM dbo.Pilot
    WHERE (Include = 1)

    take note of this " Pilot_Name + ' ' + Emp_No AS Pilot_Names" i added it on my vw_Pilot (under sql 2008, database view)
    and thats it, my problems gone.

IMN logo majestic logo threadwatch logo seochat tools logo