Ramco Ramco

Ramco Ramco

  • 439
  • 3.4k
  • 545.1k

Error - Cannot convert from string to Exception

Jun 16 2021 5:54 AM

Hi

  I am getting error -  Cannot convert from string[] to System.Exception

 var errors = query.ToArray();
                    ExceptionLogging.SendExcepToDB(errors);

 

public static void SendExcepToDB(Exception exdb)
        {
            connecttion();
            exepurl = HttpContext.Current.Request.Url.ToString();
            SqlCommand com = new SqlCommand("ExceptionLoggingToDataBase", con);
            com.CommandType = CommandType.StoredProcedure;
            com.Parameters.AddWithValue("@ExceptionMsg", exdb.Message.ToString());
            com.Parameters.AddWithValue("@ExceptionType", exdb.GetType().Name.ToString());
            com.Parameters.AddWithValue("@ExceptionURL", exepurl);
            com.Parameters.AddWithValue("@ExceptionSource", exdb.StackTrace.ToString());
            com.ExecuteNonQuery();
        }

Thanks


Answers (3)