public string GetLatestNotPaidContract(string crmUserId) { string sql = string.Format(@"select top 1 {0} from {1} where new_hindivclintname = N'{2}' and statuscode = N'100000006' order by createdon desc", CrmGuidFieldName, CrmEntityName, crmUserId); return(Convert.ToString(CRMAccessDB.ExecuteScalar(sql))); }