In the database I created a stored procedure
ALTER procedure [dbo].[usercusdet_pro](@user varchar(25),@cusname varchar(max))--,@cnt int)
as
begin
--declare @count int
--set @count=0
--if(@count<@cnt)
insert usercusdet values(@user,@cusname)
end
to insert values. When I click the button, multiple rows should be inserted in the table.
int cnt = gvTranferRows.Rows.Count;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["gdb"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("usercusdet_pro", con);
cmd.CommandType = CommandType.StoredProcedure;
if (con.State == ConnectionState.Closed)
con.Open();
for (int i=0;i<cnt;i++)
{
cmd.Parameters.Add("@user", SqlDbType.VarChar).Value = "A001";
cmd.Parameters.AddWithValue("@cusname",gvTranferRows.Rows[i].Cells[0].Text);
//cmd.Parameters.AddWithValue("@cnt", cnt);
cmd.ExecuteNonQuery();
}
When I try to add value it shows an error:
procedure or function has too many arguments specified
What's the cause of this error?