The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Visual Basic Programming
|
Procedure or function expects parameter
Discuss Procedure or function expects parameter in the Visual Basic Programming forum on Dev Shed. Procedure or function expects parameter Visual Basic Programming forum discussing VB specific programming information. Quickly prototype and build applications with this robust and simple language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 12th, 2012, 08:35 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 5
Time spent in forums: 1 h 20 m 16 sec
Reputation 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.
|

September 13th, 2012, 06:47 PM
|
 |
JavaScript is not spelt java
|
|
Join Date: Feb 2011
Location: Landan, England
|
|
|
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.
Last edited by AndrewSW : September 13th, 2012 at 06:50 PM.
|

September 13th, 2012, 10:47 PM
|
|
Registered User
|
|
Join Date: Sep 2012
Posts: 5
Time spent in forums: 1 h 20 m 16 sec
Reputation 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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|