Here is the solution. Please make the changes as per your requirement.
using(SqlConnection connection = new SqlConnection(@"data source=ABC; persist security info=True;initial catalog=ini"))
{
using(SqlCommand command = new SqlCommand(sql, connection))
{
try
{
connection.Open();
for (int i =0; i< gridView1.RowCount; i++)
{
SqlParameter parameter = new SqlParameter();
parameter.ParameterName = "@Num";
parameter.SqlDbType = SqlDbType.NVarChar;
parameter.Direction = ParameterDirection.Input;
parameter.Value = Convert.ToString(gridView1.GetRowCellValue(i, "Number"));
command.Parameters.Add(parameter);
}
command.ExecuteNonQuery();
}
catch(Exception)
{
}
}
}
Cheers,
Praveen Nelge