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 question.(5)

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

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/How to avoid the error "There is no argument given that corresponds to the required formal parameter"?
Next
Answered
Rayna O'Ryan
  • 10
Rayna O'Ryan
Asked: May 17, 20222022-05-17T14:18:23+00:00 2022-05-17T14:18:23+00:00In: csharp

How to avoid the error “There is no argument given that corresponds to the required formal parameter”?

  • 10

. Advertisement .

..3..

. Advertisement .

..4..

I am working on csharp, but I found the following warning message:

Error CS7036 There is no
 argument given that corresponds to the required formal parameter
 'errorMsg' of 'ErrorEventArg.ErrorEventArg(string,
 string)' MSSQLTest C:\Users\Administrator\Desktop\MSSQLTest\MSSQLTest\MSSQLConnection.cs 61

Is there any way to stabilize the issue “There is no argument given that corresponds to the required formal parameter”? I read a lot of topics about this, but all of them were trying to install anything. Is this the correct way, or any recommendation for me? Please find the beginning command below:

using System;
 using System.Collections.Generic;
 using System.Data.SqlClient;
 using System.Threading;
 
 namespace MSSQLTest
 {
  public class ErrorEventArg : EventArgs
  {
  public string ErrorMsg { get; set; }
  public string LastQuery { get; set; }
 
  public ErrorEventArg(string errorMsg, string lastQuery)
  {
  ErrorMsg = errorMsg;
  LastQuery = lastQuery;
  }
  }
 
  public class MSSQLConnection
  {
  /// <summary>
  /// Private class objects.
  /// </summary>
  private SqlConnection sqlConnection;
  private int sqlCommandTimeout;
  private string lastQuery = string.Empty;
 
  /// <summary>
  /// Public event related objects & handler.
  /// </summary>
  public event ErrorHandler OnError;
  public delegate void ErrorHandler(MSSQLConnection sender, ErrorEventArg e);
 
  /// <summary>
  /// Class constructor.
  /// </summary>
  /// <param name="sqlConnection"></param>
  /// <param name="sqlCommandTimeout"></param>
  public MSSQLConnection(SqlConnection sqlConnection, Int32 sqlCommandTimeout = 120)
  {
  if (null == sqlConnection)
  throw new Exception("Invalid MSSQL Database Conection Handle");
 
  if (sqlConnection.State != System.Data.ConnectionState.Open)
  throw new Exception("MSSQL Database Connection Is Not Open");
 
  this.sqlConnection = sqlConnection;
  this.sqlCommandTimeout = sqlCommandTimeout;
  }
 
  /// <summary>
  /// Helper method to emit a database error to event subscribers.
  /// </summary>
  /// <param name="errorMsg"></param>
  internal void EmitError(String errorMsg)
  {
  var errorDelegate = OnError;
  if (errorDelegate != null)
  {
  errorDelegate(this, new ErrorEventArg() // Line #61
  {
  ErrorMsg = errorMsg,
  LastQuery = lastQuery
  });
  }
  }
  
  /// rest of the code snipped
  }
 }
there is no argument
  • 2 2 Answers
  • 391 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    dttutoria Expert
    2022-06-09T04:48:46+00:00Added an answer on June 9, 2022 at 4:48 am

    The cause: Because the old MSSQL Connection helper library was refactored, or because a default constructor was not created, you get the error: There is no argument given that corresponds to the required formal parameter

    Solution: You’ve had a constructor with two parameters. You ought to write a short code like:

    new ErrorEventArg(errorMsv, lastQuery)

    Alternatively, you may write a default constructor for ErrorEventArg that takes no parameters, such as this:

    public ErrorEventArg() {}
    • 7
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Zoé Renard
    2022-05-25T20:06:33+00:00Added an answer on May 25, 2022 at 8:06 pm

    The constructor of

    public class ErrorEventArg : EventArgs

    You will need to add “base” in the following order:

    public ErrorEventArg(string errorMsg, string lastQuery) : base (string errorMsg, string lastQuery)
    {
     ErrorMsg = errorMsg;
     LastQuery = lastQuery;
    }
    • 12
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

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.