locked
How to log error message RRS feed

  • Question

  • User1979860870 posted

    Hi

     I have below code . I passed int parameter , though field is string . I want to save Error Message in Database. 

    Can Elmah be implemented or any other way to save Error Logs in Database Sql

    Thanks

    Sunday, March 7, 2021 3:56 PM

All replies

  • User475983607 posted

     I have below code . I passed int parameter , though field is string . I want to save Error Message in Database. 

    Can Elmah be implemented or any other way to save Error Logs in Database Sql

    You did not provide any code.  If you want to use Elmah then read the documentation for the framework you are using.  There's literally tons of information...  So, at this point it is not cleat what problem you are having. It seems like you have not even tried...

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-getting-started/deploying-web-site-projects/logging-error-details-with-elmah-cs

    Sunday, March 7, 2021 4:05 PM
  • User1979860870 posted

    Hi

     Below is the Code. Parameter in Object is string but here i have given int.

    public IHttpActionResult DeleteEmployee(int Id)
            {
                try
                {
                    Employee employee = db.Employees.Find(Id);
                    if (employee == null)
                    {
                        //return BadRequest("Error Encountered : ");
                        return Content(HttpStatusCode.NotFound, "Employee not found");
                    }
                    else
                    {
                        db.Employees.Remove(employee);
                        db.SaveChanges();
                        return Ok();
                    }
                }
                catch (Exception ex)
                {
                    return BadRequest("Error Encountered : " + ex);
                }
            }

    Thanks

    Monday, March 8, 2021 9:27 AM
  • User475983607 posted

    Below is the Code. Parameter in Object is string but here i have given int.

    If "Id" is a string the declare it as a string.

    public IHttpActionResult DeleteEmployee(string Id)

    Monday, March 8, 2021 12:26 PM