I'm getting error like
Procedure or function has too many arguments specified
but i have specified the arguments correctly
my procedure
CREATE PROCEDURE [dbo].[rsa_products_sp_Insertordersummary]
@UserId int,
@productid int,
@productname NVARCHAR(50),
@ProductImage image,
@price float,
@qty int,
@totalcost decimal(18, 2)
AS
BEGIN
SET NOCOUNT ON;
IF NOT EXISTS(SELECT * FROM rsa_Orderconfirmation WHERE productid=@productid)
INSERT INTO [rsa_Orderconfirmation]
([UserId]
,[productid]
,[productname]
,[ProductImage]
,[price]
,[qty]
,[totalcost]
,[cdate])
VALUES
(@UserId
,@productid
,@productname
,@ProductImage
,@price
,@qty
,@totalcost
,GETDATE())
END
GO
My cs code as follows
foreach (GridViewRow gvr in Gridcart.Rows)
{
string ProductID = Gridcart.DataKeys[gvr.RowIndex].Values["productid"].ToString();
Application["id"] = ProductID;
string proid = Application["id"].ToString();
da = new SqlDataAdapter("select tpd.productid,tpd.productname,tpd.ProductImage,tpd.price,tpd.qty,tpd.totalcost,tpd.cdate from rsa_addtocart tpd where tpd.productid=" + proid + "", con);
ds = new DataSet();
da.Fill(ds, "tbl_tpd");
if (ds.Tables.Count > 0 && ds.Tables["tbl_tpd"].Rows.Count > 0)
{
using (var command = new SqlCommand("rsa_products_sp_Insertordersummary", con))
{
foreach (DataRow theRow in ds.Tables["tbl_tpd"].Rows)
{
command.Parameters.Clear();
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@UserId", Session["users"]);
command.Parameters.AddWithValue("@productid", ds.Tables[0].Rows[0]["productid"]);
command.Parameters.AddWithValue("@productname", ds.Tables[0].Rows[0]["productname"]);
command.Parameters.AddWithValue("@ProductImage", ds.Tables[0].Rows[0]["ProductImage"]);
command.Parameters.AddWithValue("@price", ds.Tables[0].Rows[0]["price"]);
command.Parameters.AddWithValue("@qty", ds.Tables[0].Rows[0]["qty"]);
command.Parameters.AddWithValue("@totalcost", ds.Tables[0].Rows[0]["totalcost"]);
command.Parameters.AddWithValue("@cdate", DateTime.Now);
if (con.State != ConnectionState.Open)
{
con.Open();
try
{
command.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
else
{
command.ExecuteNonQuery();
con.Close();
}
}
}
}
}
What I'm doing wrong in the stored procedure please help me to solve this.