Friday, October 21, 2011

C# LINQ Search between date

The SQL BETWEEN operator we can use in C# code. Before your query you have to use
System.Globalization.CultureInfo culInfo = new System.Globalization.CultureInfo("en-US");  

Consider the Example:
internal List<ECalendarSetup> GetCalenderInfoOnSelectedDate(ECalendarSetup calendarSetup)
            ieclHrmDataContext = new IECL_HRMDataContext();
            List<ECalendarSetup> calendarSetupsList = new List<ECalendarSetup>();
            var query = from j in ieclHrmDataContext.HR_CALENDAR_INFOs
                        where j.CAL_DAY_DATE >= calendarSetup.FromDate && j.CAL_DAY_DATE <= calendarSetup.ToDate
                        select j;
            foreach (var calendarInfo in query)
                ECalendarSetup eCalendarSetup = new ECalendarSetup();
                eCalendarSetup.Date = (DateTime) calendarInfo.CAL_DAY_DATE;
                eCalendarSetup.DayStatus = calendarInfo.CAL_DAY_STATUS;
                eCalendarSetup.StartTime = calendarInfo.CAL_START_TIME.ToString();
                eCalendarSetup.EndTime = calendarInfo.CAL_END_TIME.ToString();
                eCalendarSetup.Remarks = calendarInfo.CAL_REMARKS;
            return calendarSetupsList;


vfpoledeb.1 provider is not registered on the local machine

Have u Install VFP Ole DB Provider in your System ? If No then Please Install it from following link.