hi iam using this code for datagrid row storage while check data is exist or not in DB sql server 2008

Code:
cmd.Parameters["@pname"].Value = row.Cells["gpname"].Value;
cmd.Parameters["@cstock"].Value = row.Cells["gcstock"].Value;
cmd.Parameters["@ondate"].Value = DateTime.Now;
check();
after to debug in comes in check function first time hasrow function...