Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6343611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:28:23+00:00 2026-05-24T20:28:23+00:00

Here is the code: internal static void UpdateErrorLogTable(string type, string location, string method, Exception

  • 0

Here is the code:

internal static void UpdateErrorLogTable(string type, string location, string method, Exception _error, string ftpDirectory, string remoteName, string localName)
    {
        try
        {
            using (SqlConnection databaseConnection = GetDatabaseConnection())
            {
                using (SqlCommand cmd = GetSqlCommand("ins_error_log", databaseConnection))
                {
                    SqlParameter log_date = cmd.Parameters.Add("@log_date", SqlDbType.DateTime);
                    SqlParameter exception_type = cmd.Parameters.Add("@exception_type", SqlDbType.VarChar);
                    SqlParameter class_name = cmd.Parameters.Add("@class_name", SqlDbType.VarChar);
                    SqlParameter method_name = cmd.Parameters.Add("@method_name", SqlDbType.VarChar);
                    SqlParameter error_msg = cmd.Parameters.Add("@error_msg", SqlDbType.VarChar);
                    SqlParameter stack_trace_msg = cmd.Parameters.Add("@stack_trace_msg", SqlDbType.VarChar);
                    SqlParameter target_site_msg = cmd.Parameters.Add("@target_site_msg", SqlDbType.VarChar);
                    SqlParameter ftp_directory = cmd.Parameters.Add("@ftp_directory", SqlDbType.VarChar);
                    SqlParameter ftp_name = cmd.Parameters.Add("@ftp_name", SqlDbType.VarChar);
                    SqlParameter ftp_path = cmd.Parameters.Add("@ftp_path", SqlDbType.VarChar);
                    SqlParameter inner_exception_msg = cmd.Parameters.Add("@inner_exception_msg", SqlDbType.VarChar);

                    log_date.Value = m_todaysDate;
                    exception_type.Value = type;
                    class_name.Value = location;
                    method_name.Value = method;
                    error_msg.Value = _error.Message;
                    stack_trace_msg.Value = _error.StackTrace;
                    target_site_msg.Value = _error.TargetSite;
                    ftp_directory.Value = ftp_directory;
                    ftp_name.Value = remoteName;
                    ftp_path.Value = localName;
                    inner_exception_msg.Value = _error.InnerException;

                    cmd.ExecuteNonQuery();
                }
            }  // using databaseConnection
        } //end of TRY statement
        catch (SqlException e)
        {
            logFile.SendToLog("SqlException", "Logs\\LogsDataAccess.cs", "UpdateErrorLogTable()", e);
        } //end of SqlException CATCH statement
    } //end of method UpdateErrorLogTable

The error I get is an InvalidCastException but it happens when attempting to execute

cmd.ExecuteNonQuery();

The part I can’t figure out is why am I getting an InvalidCastException here and not at one of the points above where I’m assigning values. I stepped through the code in Debug line-by-line of this and it only gets the error when attempting to execute the code at that one line.

I performed a Google search for

Failed to convert parameter value from a RuntimeMethodInfo to a String

but no hits. So I searched for

convert from RuntimeMethodInfo to String

and still no luck.

To help you understand the code a little better, the statement

GetSqlCommand("ins_error_log", databaseConnection)

basically goes out and recognizes the info in quotes is a Stored Procedure and not a query string.

All this code above has been used throughout the application (written by someone else) and all I did was copy it and make the necessary modifications to the stored procedure name, the SQL parameters, and the values inserted.

I appreciate all your help!

*Note: I tried setting the TAG for this question as “RuntimeMethodInfo” but it wouldn’t let me because I have less than a 1500 reputation. Maybe someone else can do it for me or give me the permissions to handle this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:28:25+00:00Added an answer on May 24, 2026 at 8:28 pm

    It’s this line:

    target_site_msg.Value = _error.TargetSite;
    

    Exception.TargetSite is a MethodBase, not a string. Try changing to:

    target_site_msg.Value = _error.TargetSite.Name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to execute internal code via reflection? Here is an example
internal static string ReadCSVFile(string filePath) { try { ... ... } catch(FileNotFoundException ex) {
i'm trying to write simple tcp\ip client-server. here is server code: internal class Program
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
enter code here I have a table on SQL server 2005 with bigint primary
The code here is X++. I know very little about it, though I am
enter code here Hi All, I have a simple windows service application that connects
Edit: The code here still has some bugs in it, and it could do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.