Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.20/5 (2 votes)
See more:
C#
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));

        }
Posted
Comments
Ron Beyer 24-Jan-14 23:30pm    
Ok, a vague title and a code dump do not a question make. Please tell us what you need or what you are trying to accomplish.
Mitchell J. 24-Jan-14 23:31pm    
Wow, second to second comments!
Ron Beyer 24-Jan-14 23:32pm    
Well if anything we are consistent!
Mitchell J. 24-Jan-14 23:42pm    
:-)
Mitchell J. 24-Jan-14 23:30pm    
This question is not very clear. What are you trying to do?

I assume you used a nullable int return Type here so you could detect an error in updating the record.

So, why not return a null in the catch-block, so: when your method returns, you can test if the returned value is null, and handle the fact that the record was not updated ?
 
Share this answer
 
Comments
Mitchell J. 24-Jan-14 23:53pm    
Good call.
You need to return something when an error happens, to be consistent with the fact that this must return an int.

C#
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!
    }
}
 
Share this answer
 
Comments
Siva Hyderabad 24-Jan-14 23:44pm    
Thanks CraigDJ..
Mitchell J. 24-Jan-14 23:47pm    
You're welcome!
RaviRanjanKr 25-Jan-14 0:00am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900