Asp.net stored procedure with parameters
Posted on 2012-09-18
I have an ASP.NET Solution with a gridview displaying shipping load record information.
gridview is bound to this datasource sql table
loadID int (key)
The ShipID is populated by a drop downbox connected to this datasource table
The DeliveryID is populated in the gridview by datasource table
I have another table that holds the ship rates based on ship location to delivery location
sample data would be
Rateid shipID DeliveryID Rate
1 1 2 $40.00
I have this stored procedure
ALTER PROCEDURE find_rate
DECLARE @ShipID int = 1
DECLARE @DeliveryID int = 2
FROM tbl_Rate INNER JOIN
tbl_GenShip ON tbl_Rate.ShipID = tbl_GenShip.ShipID INNER JOIN
tbl_GenDairy ON tbl_Rate.DeliveryID = tbl_GenDairy.DeliveryID
WHERE (tbl_Rate.ShipID = @ShipID) AND (tbl_Rate.DeliveryID = @DeliveryID)
This procedure works and gives the correct rate based on the shipID and DeliveryID.
What I am looking for is a way to pass the parameters LoadID, ShipID and DeliveryID from my load record in the gridview, run the procedure and insert the RATE generated from the procedure in to the "rate" field in the table tbl_loadTest.
Any ideas? Thanks for the help.