title: Out of range error from C# to SQL
body: <p>I have a stored procedure as follows</p>
  
  <pre><code>create procedure [dbo].[PriceConfirm]
  @quote float,
  @membershipType int,
  @promocode nvarchar(20),
  @giftCertificateCode nvarchar(20)
  
  as
  
  if(LEN(@giftCertificateCode)&gt;1)
  begin
      declare @giftType int
      select @giftType = MembershipType from GiftCertificate where GiftCertificateCode=@giftCertificateCode
      if @giftType = @membershipType
      begin
          select 1 as result
      end
      else
      begin
          select 0 as result
      end
  end
  else
  begin
      declare @total float
      select @total = Price from MembershipType where TypeID=@membershipType
      declare @discount float
      select @discount = 0
      if(LEN(@promocode)&gt;1)
      begin
          select @discount = DiscountAmount from Membership_Promo where Promocode=@promocode and MembershipType = @membershipType
      end
      else
      begin
          select @discount=0
      end
      if ABS(@total-@discount-@quote) &lt;.01
      begin
          select 1 as result
      end
      else
      begin
          select 0 as result
      end
  end
  </code></pre>
  
  <p>And if I just execute the stored procedure in SQL Server Management Studio, it works.</p>
  
  <pre><code>exec PriceConfirm @quote=69.99, @membershipType=6, @promocode='1', @giftCertificateCode='1'
  </code></pre>
  
  <p>That returns 1, as it should.</p>
  
  <p>But in C#, when I try to pass in the parameters @quote, @membershipType, @promocode, @giftCertificateCode with the exact same values, I get an exception in the code. It reads '69.99' is out of range.</p>
  
  <p>In my table and in the stored procedures, I have the columns as floats. I just don't understand why passing in a C# double is giving me a precision error. Can anybody advise?</p>
  
  <p>Edit:</p>
  
  <p>Here's the C# code:</p>
  
  <pre><code>IDataAccess dataAccess = _dataAccessService.GetDataAccess();
          IDataConnection connection = _dataAccessService.GetConnection(Connectionstring);
          var operation = new DataOperation("PriceConfirm");
          operation.Parameters.Add(new DataParameter("@quote", DbType.Double, quote));
          operation.Parameters.Add(new DataParameter("@membershipType", DbType.Int32, membership));
          operation.Parameters.Add(new DataParameter("@promocode", DbType.String, promocode));
          operation.Parameters.Add(new DataParameter("@giftCertificateCode", DbType.String, giftcode));
          IResultSet reader = dataAccess.ExecuteResultSet(connection, operation, ResultSetType.Reader);
  </code></pre>
  
  <p>Reader is null after it tries to execute the operation. It throws an exception saying that "Data Parameter '69.99' is out of range."</p>