I have wrote a webservice in asp.net which just insert values into table via store procedure. Webservice is accessed via an android app. My service should just return TRUE (in case of insertion) or FALSE(in case of failed insertion) but it could also raise errors (exceptions) which looks weird and ordinary user cannot understand technical terms so how to hide these details and to display a proper message (or redirection). THere could be many errors e.g. Outofrange exception, NullException etc.

WebServive:

```
public GPSWebservice () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public bool insertCoordinates(string param) 
    {
        BLL bll = new BLL();
        return bll.InsertCoordinates(param);
    }

}

```

BLL

```
public bool InsertCoordinates(string param) 
    {

        String[] parts = param.Split(',');
        sqlCom.CommandText = "InsertCoordinates";
        sqlCom.CommandType = CommandType.StoredProcedure;
        bool result ;

        sqlCom.Parameters.Add("@AddedDateTime", SqlDbType.VarChar).Value = Convert.ToDateTime(parts[0].ToString());
        sqlCom.Parameters.Add("@IMEI", SqlDbType.VarChar).Value = parts[1].ToString();
        sqlCom.Parameters.Add("@RecordedDateTime", SqlDbType.VarChar).Value = Convert.ToDateTime(parts[2].ToString());
        sqlCom.Parameters.Add("@Latitude", SqlDbType.VarChar).Value = parts[3].ToString(); ;
        sqlCom.Parameters.Add("@Longitude", SqlDbType.VarChar).Value = parts[4].ToString(); ;
        sqlCom.Parameters.Add("@IsParking ", SqlDbType.Bit).Value = ((parts[5].ToString().Trim()).Equals("0")) ? false : true;
        SqlParameter sqlParam = new SqlParameter("@result", SqlDbType.Int);
        sqlCom.Parameters.Add(sqlParam);
        sqlCom.Parameters["@result"].Direction = ParameterDirection.Output;

        try
        {
            sqlCon.Open();
            sqlCom.ExecuteNonQuery();
            return result = Convert.ToBoolean(sqlParam.Value);
        }

        catch (Exception ex)
        {

            return false; 

        }

        finally 
        {
            sqlCon.Close();
        }

    }
}

```

SP:

```
ALTER PROCEDURE [dbo].[InsertCoordinates]

    @AddedDateTime varchar(50),
    @IMEI varchar(50),
    @RecordedDateTime varchar(50),
    @Latitude varchar(50),
    @Longitude varchar(50),
    @IsParking bit,
    @result int output
AS

BEGIN

    SET NOCOUNT ON;
   Begin Try

    If Not exists(select IMEI from dbo.Coordinates where IMEI =@IMEI AND Latitude=@Latitude AND @Longitude=@Longitude)
    Begin
        insert into dbo.Coordinates 
        values (@AddedDateTime, @IMEI, @RecordedDateTime, @Latitude, @Longitude, @IsParking) 

        Set @result = @@ROWCOUNT

        IF(@result = 1)
         Select @result
        Else
         Set @result=0
         Select @result
    End

    Else
    Begin
         Set @result=0
         Select @result
    End
   End Try

   Begin Catch
        Set @result=0
   End Catch

END 

```