Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 SQL SERVER 2008中的输出参数有问题_Sql Server 2008 - Fatal编程技术网

Sql server 2008 SQL SERVER 2008中的输出参数有问题

Sql server 2008 SQL SERVER 2008中的输出参数有问题,sql-server-2008,Sql Server 2008,我有这样一种方法:- public List<InterestedParty> GetDealViewData(string username,Guid opportunityId, int fromIndex, int toindex, string IPStatus, Guid? JllBroker, string ipsearch,ref string sortby, ref string direction, out int totalRecords, int offerTy

我有这样一种方法:-

public List<InterestedParty> GetDealViewData(string username,Guid opportunityId, int fromIndex, int toindex, string IPStatus, Guid? JllBroker, string ipsearch,ref string sortby, ref string direction, out int totalRecords, int offerType)
{
            if (sortby == null)
                sortby = string.Empty;

            if (direction == null)
                direction = string.Empty;

            InterestedPartyMapper interestedPartyMapper = new InterestedPartyMapper();
            InterestedParty dummyIP = new InterestedParty();

            SqlParameter outParam = new SqlParameter();
            outParam.ParameterName = "@TotalRecords";
            outParam.SqlDbType = SqlDbType.Int;
            outParam.Direction = ParameterDirection.Output;

            SqlParameter sortParam = new SqlParameter();
            sortParam.ParameterName = "@sortby";
            sortParam.SqlDbType = SqlDbType.VarChar;
            sortParam.Size = 500;
            sortParam.Value = sortby.Trim();
            sortParam.Direction = ParameterDirection.InputOutput;

            SqlParameter dirParam = new SqlParameter();
            dirParam.ParameterName = "@direction";
            dirParam.SqlDbType = SqlDbType.VarChar;
            dirParam.Size = 500;
            dirParam.Value = direction.Trim();
            dirParam.Direction = ParameterDirection.InputOutput;

            IEnumerable<InterestedParty> interestedParties = DatabaseUtility.ExecuteReader<InterestedParty>(DatabaseUtility.DataWarehouseConnectionString,
                            "cp_GetDealViewInterestedParties",
                            CommandType.StoredProcedure,
                            new SqlParameter[] { new SqlParameter("@opportunityid", opportunityId),
                            new SqlParameter("@fromIndex", fromIndex),
                            new SqlParameter("@toindex", toindex),
                            new SqlParameter("@ipstatus", IPStatus),
                            new SqlParameter("@jllbroker", JllBroker),
                            new SqlParameter("@IPNameSearch", ipsearch),
                            new SqlParameter("@domainname", username),
                            sortParam,
                            dirParam,
                            new SqlParameter("@offerType", offerType),
                            outParam},
                            interestedPartyMapper.Mapper);
            totalRecords = Convert.ToInt32(outParam.Value);
            sortby = sortParam.Value.ToString();
            direction = dirParam.Value.ToString();
            return interestedParties.ToList();
}
我得到以下错误:

形式参数“@sortby”未声明为输出参数,而是传入请求输出的实际参数


在您的代码中,您将“@sortby”定义为varchar,而您的存储过程需要一个nvarchar类型。改变这一点可以解决问题吗

        SqlParameter sortParam = new SqlParameter();
        sortParam.ParameterName = "@sortby";
        sortParam.SqlDbType = SqlDbType.VarChar; //<---- should be nvarchar?
        sortParam.Size = 500;
        sortParam.Value = sortby.Trim();
        sortParam.Direction = ParameterDirection.InputOutput;



-- sql def: @sortby nvarchar(255) OUTPUT,
SqlParameter sortParam=newsqlparameter();
sortParam.ParameterName=“@sortby”;
sortParam.SqlDbType=SqlDbType.VarChar//
        SqlParameter sortParam = new SqlParameter();
        sortParam.ParameterName = "@sortby";
        sortParam.SqlDbType = SqlDbType.VarChar; //<---- should be nvarchar?
        sortParam.Size = 500;
        sortParam.Value = sortby.Trim();
        sortParam.Direction = ParameterDirection.InputOutput;



-- sql def: @sortby nvarchar(255) OUTPUT,