title: Error converting data type varchar to int
body: <p>This is my stored procedure code </p>
  
  <pre><code>ALTER procedure [Proc_Add_User]
      (@UserId varchar(20), 
       @UserName varchar(100),
       @Page_Name varchar(20), 
       @AccessIndicator int, 
       @CreatedBy varchar(50), 
       @returnStatus varchar(50) output)
  as
     DECLARE @intErrorCode INT
  DECLARE @Page_Indicator INT
  begin
  BEGIN TRAN
  Set @Page_Indicator = (select Page_Indicator from Pages where Page_Name=@Page_Name);
  if (select count(*) from Users where UserId=@UserId and UserName=@UserName) &gt; 0 begin               
      if (select count(*) from User_Credentials where Page_Indicator=@Page_Indicator and 
      UserId=@UserId  ) &gt; 0 
      set @returnStatus='User already has access'             
      else 
      insert into User_Credentials(UserId,Page_Indicator,Access_Indicator,CreatedBy) 
          values (@UserId,@Page_Indicator,@AccessIndicator,@CreatedBy)
      SELECT @intErrorCode = @@ERROR
      IF (@intErrorCode &lt;&gt; 0) GOTO PROBLEM            
  end
  else begin  
      insert into Users(UserId,UserName,CreatedBy) 
      values(@UserId,@UserName,@CreatedBy)
      SELECT @intErrorCode = @@ERROR
      IF (@intErrorCode &lt;&gt; 0) GOTO PROBLEM
      insert into User_Credentials(UserId,Page_Indicator,Access_Indicator,CreatedBy) 
          values (@UserId,@Page_Indicator,@AccessIndicator,@CreatedBy)
      SELECT @intErrorCode = @@ERROR
      IF (@intErrorCode &lt;&gt; 0) GOTO PROBLEM    
  end
  COMMIT TRAN
  if(@returnStatus is null)
      set @returnStatus='Success';
  PROBLEM:
  IF (@intErrorCode &lt;&gt; 0) BEGIN
  set @returnStatus= 'Unexpected error occurred!'
  ROLLBACK TRAN
  end
  end
  </code></pre>
  
  <p>And I am calling this from the code pasted below:</p>
  
  <pre><code>Con.Open();
  cmd = new OleDbCommand();
  cmd.Connection = Con;
  
  cmd.CommandType = CommandType.StoredProcedure;
  cmd.CommandText = "Proc_Add_User";
  
  cmd.Parameters.Clear();
  cmd.Parameters.Add("@UserId", SqlDbType.VarChar).Value = userLanId;
  cmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = userName;
  cmd.Parameters.Add("@Page_Name", SqlDbType.VarChar).Value = pageName;
  cmd.Parameters.Add("@AccessIndicator", SqlDbType.Int).Value = accessIndicator;
  cmd.Parameters.Add("@CreatedBy", SqlDbType.VarChar).Value = createdBy;
  
  OleDbParameter output = new OleDbParameter("@returnStatus", SqlDbType.VarChar);
  output.Direction = ParameterDirection.Output;
  cmd.Parameters.Add(output); 
  
  int result = cmd.ExecuteNonQuery();
  </code></pre>
  
  <p>I am getting the error mentioned at the <code>ExecuteNonQuery</code> statement. What's confusing to me is I am able to execute the stored procedure in SSMS but not from my application (front-end). I provided the same values too yet it fails from my app.</p>
  
  <p>I double checked to make sure the order of parameters passed match and are of same data type but still it throws this error. I can paste my stored proc code here if wanted so let me know..Thanks in advance!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>OOPS! I just realized that all the inserts are all happening and getting committed fine in the database. It's just this error is getting caught inside catch block in my app. Any ideas? </p>
  
  <p>I can not ignore it because based on the return value of ExecuteNonQuery(), I have some statements and also it's not going through the code present after ExecuteNonQuery().</p>