本文介绍了怎么给Try,catch块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public int? FarmInfraDetailsUpdate(FarmRecordPL FormrecordPL)
        {

            SqlParameter[] arParams = new SqlParameter[7];

            arParams[0] = new SqlParameter("@shedid", typeof(int));
            arParams[0].Value = FormrecordPL.shedid;


            arParams[1] = new SqlParameter("@shedno", typeof(int));
            arParams[1].Value = FormrecordPL.shedno;


            arParams[2] = new SqlParameter("@length", typeof(int));
            arParams[2].Value = FormrecordPL.length;

            arParams[3] = new SqlParameter("@width", typeof(int));
            arParams[3].Value = FormrecordPL.width;

            arParams[4] = new SqlParameter("@totalarea", typeof(int));
            arParams[4].Value = FormrecordPL.totalarea;

            arParams[5] = new SqlParameter("@capacity", typeof(int));
            arParams[5].Value = FormrecordPL.capacity;

            arParams[6] = new SqlParameter("@username", typeof(string));
            arParams[6].Value = FormrecordPL.capacity;

            return Convert.ToInt16(SqlHelper.ExecuteScalar(connection.ConnectionString, CommandType.StoredProcedure, "k_UpdateFarmRecordInfraDetail", arParams));

        }

推荐答案

public int? FarmInfraDetailsUpdate(FarmRecordPL FormrecordPL)
{
    try
    {
        //Your code...
        return Convert.ToInt16(SqlHelper.ExecuteScalar(connection.ConnectionString, CommandType.StoredProcedure, "k_UpdateFarmRecordInfraDetail", arParams));

    }
    catch
    {
        //Now you need to return something else
        return 0; //Just a suggestion!
    }
}



这篇关于怎么给Try,catch块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 11:02