The procedure for Insert/update.I use datagridview get and display the data.
I get the error message
"Procedure or function Updatedata has too many arguments specified."
// this is my Procedure
ALTER PROCEDURE [dbo].[Updatedata]
@item char(30),
@uom int,@group int,@orqty int,@avgcons int,@reorder int
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS( SELECT * FROM P_Itemmaster WHERE Item=@item )
UPDATE P_Itemmaster SET Uom=@uom,PGroup=@group,Minorqty=@orqty,avgcons=@avgcons,reorder=@reorder where item=@item
ELSE
INSERT INTO P_Itemmaster (Item,Uom,PGroup,Minorqty,Avgcons,reorder)Values(@item,@uom,@group,@orqty,@avgcons,@reorder)
END
//call the procedure in the program
Private Sub Updatetable()
conn = New SqlConnection(frmstlogin.Constr)
conn.Open()
cmd = New SqlCommand(cmdstr, conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "Updatedata"
Dim MUom As Integer, Mgroup As Integer, Morqty As Integer, Mavgcons As Integer, Mreorder As Integer
For i = 0 To Dgvitem.Rows.Count - 2
Mitem = Dgvitem.Item(1, i).Value
MUom = Dgvitem.Item(2, i).Value
Mgroup = Dgvitem.Item(3, i).Value
Morqty = Dgvitem.Item(4, i).Value
Mavgcons = Dgvitem.Item(5, i).Value
Mreorder = Dgvitem.Item(6, i).Value
cmd.Parameters.AddWithValue("@Item", Mitem)
cmd.Parameters.AddWithValue("@Uom", MUom)
cmd.Parameters.AddWithValue("@Group", Mgroup)
cmd.Parameters.AddWithValue("@orqty", Morqty)
cmd.Parameters.AddWithValue("@Avgcons", Mavgcons)
cmd.Parameters.AddWithValue("@Reorder", Mreorder)
cmd.ExecuteNonQuery()
Next
End Sub