public void savedlogic() { try { int a = Convert.ToInt32(Session["company_id"]); int s = Convert.ToInt32(ddlState.SelectedValue); string user = Session["UserID"].ToString(); SqlCommand cmd = new SqlCommand(); if (fileuplogo.HasFile) { HttpPostedFile postedFile = fileuplogo.PostedFile; string filename = Path.GetFileName(postedFile.FileName); string fileExtension = Path.GetExtension(filename); int fileSize = postedFile.ContentLength; if (fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".png") { //Stream stream = postedFile.InputStream; //BinaryReader binaryReader = new BinaryReader(stream); //Byte[] bytes = binaryReader.ReadBytes((int)stream.Length); fileuplogo.SaveAs(Server.MapPath("~/Uploads/" + filename)); string imagepath = "~/Uploads/" + filename; tbl_company company = new tbl_company(); company.company_id = a; company.company_name = txtName.Text; company.company_address = txtAddress.Text; company.state_id = s; company.city = txtCity.Text; company.telephone_no = txttelephoneno.Text; company.fax_no = txtFaxno.Text; company.website = txtwebsite.Text; company.logo = imagepath; company.logo_name = filename; company.GSTIN = txtGSTIN.Text; company.modified_by = user; company.modified_date = DateTime.Now; context.Entry(company).State = EntityState.Modified; context.SaveChanges(); //context.tbl_company.(company); //context.SaveChanges(); } } } catch (Exception ex) { ErrorLog.saveerror(ex); } }