Skip to main content

Posts

An error occurred while updating the entries. See the inner exception for details.

If you are using EF then you may get the error. This error is not specify where the error exactly occur in your table. To specify the error use this code & use debugger to see the exact error message. try { //Your code db = new FEDALIC_AGRI_DBEntities (); model.FarmerVillage = new Guid(village); model.FarmerThana = new Guid(thana); model.FarmerDistrict = new Guid(district); var _SET_FARMER_INFO = EMFermar.SetToModelObject(model); db.SET_FARMER_INFO.Add(_SET_FARMER_INFO); db.SaveChanges(); } catch (DbUpdateException e) { var innerEx = e.InnerException; while (innerEx.InnerException != null) innerEx = innerEx.InnerException; throw new Exception(innerEx.Message); } catch (DbEntityValidationException e...

Kendo UI web Grid how to set default null values to a grid when adding new row

In your Kendo UI web grid model binding just use '?' allow null in your model class property. Which property you want to use in your grid as nullable. Model : [Key] public System.Guid? CompanyId { get; set; } public System.String CompanyName { get; set; } public System.String CompanyAddress { get; set; } Kendo Grid : .Columns(columns => { columns.Bound(p => p.CompanyId).Hidden(); columns.Bound(p => p.CompanyName).Width(200); columns.Bound(p => p.CompanyAddress).Width(300); columns.Command(command => { command.Edit(); command.Destroy();}).Width(172); }) UI

how to pass the multiple values in session ASP.NET

Set Value in session // Set value in one UI in session string empIdList = GetSelectedIDofGrid(); var paramObjects = new Dictionary<string, object> { {"paramEmployeeXmlstr", empIdList}, {"paramFactoryId", ddlFactoryName.SelectedValue} }; Session["paramPayroll_RPT014_Staff"] = paramObjects; Get value from session // Get Value in another UI From session private string _paramEmployeeXmlstr = String.Empty; private string _paramFactoryId = String.Empty; var paramObjects = Session["paramPayroll_RPT014_Staff"] as Dictionary<string, object>; if (paramObjects != null) { _paramEmployeeXmlstr = (string)paramObjects["paramEmployeeXmlstr"]; _paramFactoryId = (string)paramObjects["paramFactoryId"]; }

sql row value wise count

Query: SELECT COUNT(CASE WHEN DayStatusID = 1 THEN 1 END) AS A, COUNT(CASE WHEN DayStatusID = 7 THEN 1 END) AS B, COUNT(CASE WHEN DayStatusID = 3 THEN 1 END) AS C from Payroll_tblYearMonthDayEntry Result:

C# allow nullable value get from EF

You can get value from Entity framework which can allow null able and you can also perform filtering in your query. private static IQueryable<EmployeeInformation> ReportFilteringEmployeeInformations(Guid factoryId, Guid departmentId, Guid designationId, string empId, string empName, Guid sectionId, Guid categoryEmpId, int? CategoryTypeID, Guid categorySalaryID, Guid blockID,string cardNo, PayrollEntities context) { var query = from emp in context.vw_PIS_TblEmployeeGenInfo join des in context.vw_PIS_TblEmployeeDesignation on emp.GDesignationInfoID equals des.GDesignationInfoID into des_J join dept in context.vw_PIS_tblDepartment on emp.GDepartmentID equals dept.GDepartmentID into dept_J join sec in context.vw_PIS_TblSection on emp.SectionID equals sec.SectionID into sec_J from des1 in des_J.DefaultIfEmpty() from dept1 in dept_J.DefaultIfEmpty() from sec1 in sec_J.D...

Schedule Mail Sending with attachment file ASP.NET MVC

For scheduling mail i am using JobcashAction. It's simple Open your Global.asax.cs file just use the following code. public class MvcApplication : System.Web.HttpApplication { // Define Path Of the Job private const string JobCashAction = "http://localhost:38416/Home/AddJobCache"; protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AuthConfig.RegisterAuth(); } protected void Application_BeginRequest(object sender, EventArgs e) { if (HttpContext.Current.Cache["jobkey"] == null) { HttpContext.Current.Cache.Add("jobkey", "jobvalue", null, ...