Question The Best Overload Match has some invalid arguments

parikshit64

New member
Joined
Jan 18, 2022
Messages
2
Programming Experience
Beginner
Hi Friends,

Unable to figure out the error in this line

The Best Overload Match has some invalid arguments.

lParamerterList1.Add(new DataType("@I_USERNO", SqlDbType.Int,44, ParameterDirection.Input));

tempsnip.png


Here the value 44 is not being accepted even if the any other variable is passed

This is the contructer class code for the same
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Core.HelperClasses.Generic
{
    [Serializable()]
    public class DataType
    {
        private string _ParameterName;
        private DbType _DbType;
        private object _Value;
        private ParameterDirection _Direction;

        public string ParameterName
        {
            get { return _ParameterName; }
            set { _ParameterName = value; }
        }

        public DbType dbType
        {
            get { return _DbType; }
            set { _DbType = value; }
        }

        public object Value
        {
            get { return _Value; }
            set { _Value = value; }
        }

        public ParameterDirection Direction
        {
            get { return _Direction; }
            set { _Direction = value; }
        }

        public DataType()
        {
        }

        public DataType(string ParameterName, DbType dbType, object Value, ParameterDirection Direction)
        {
            this.ParameterName = ParameterName;
            this.dbType = dbType;
            this.Value = Value;
            this.Direction = Direction;
        }
    }
}


Help would be appreciated

Thank You
Park
 
Solution
The problem is not the 44, but rather the SqlDbType.Int.

Your class constructor's second parameter is DbType. In your call to the constructor you are passing in a SqlDbType.
The problem is not the 44, but rather the SqlDbType.Int.

Your class constructor's second parameter is DbType. In your call to the constructor you are passing in a SqlDbType.
 
Last edited:
Solution
OT: Unless you intend to make the properties more complex in future, this:
C#:
private string _ParameterName;
private DbType _DbType;
private object _Value;
private ParameterDirection _Direction;

public string ParameterName
{
    get { return _ParameterName; }
    set { _ParameterName = value; }
}

public DbType dbType
{
    get { return _DbType; }
    set { _DbType = value; }
}

public object Value
{
    get { return _Value; }
    set { _Value = value; }
}

public ParameterDirection Direction
{
    get { return _Direction; }
    set { _Direction = value; }
}
should be this:
C#:
public string ParameterName { get; set; }
public DbType DbType { get; set; }
public object Value { get; set; }
public ParameterDirection Direction { get; set; }
 
Back
Top Bottom