i want to pass multiple rows to database..i tried below code but only first row inserting after then error raising..
public static bool SaveChitGroupDetails(List<ChitGroup> lst)
{
try
{
_dal = DataLayer.GetInstance();
_dal.Sql = StoredProcedures.SaveChitGroupDetails;
_dal.CommandType = CommandType.StoredProcedure;
foreach (ChitGroup obj in lst)
{
_dal.AddParameter("_grcode", obj.GrpCode, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_brid", obj.Brid, DbType.Int16, ParameterDirection.Input);
_dal.AddParameter("_prdcode", obj.Prdcode, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_valuecode", obj.Valuecode, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_companychit", obj.Companychit, DbType.Boolean, ParameterDirection.Input);
_dal.AddParameter("_series", obj.Series, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_status", obj.Status, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_bylawnumber", obj.Bylawnumber, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_registrationdate", obj.RegistrationDate, DbType.Date, ParameterDirection.Input);
_dal.AddParameter("_commencedate", obj.CommenceDate, DbType.Date, ParameterDirection.Input);
_dal.AddParameter("_terminatedate", obj.TerminateDate, DbType.Date, ParameterDirection.Input);
_dal.AddParameter("_maxdiscount", obj.MaxDiscount, DbType.Int16, ParameterDirection.Input);
_dal.AddParameter("_active", obj.Active, DbType.Boolean, ParameterDirection.Input);
_dal.AddParameter("_userid", obj.Userid, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_amndmntdate", obj.AmendmentDate, DbType.Date, ParameterDirection.Input);
_dal.AddParameter("_amndtrmntdate", obj.AmendTerminateDate, DbType.Date, ParameterDirection.Input);
_dal.AddParameter("_description", obj.Description, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_docno", obj.DocNo, DbType.String, ParameterDirection.Input);
_dal.AddParameter("_assignedvalue", obj.AssignedValue, DbType.Decimal, ParameterDirection.Input);
_dal.AddParameter("_type", obj.Type, DbType.String, ParameterDirection.Input);
int rtrnid = _dal.ExecuteNonQuery();
}
return true;
}
catch (Exception ex)
{
throw ex;
return false;
}
finally
{
if (_dal.Connected)
_dal.Connection.Close();
}
}