Re: Conversion problem SqlDBType.Decimal -> T-SqlType Decimal (12,6)

P_at_rick
Date: 05/28/04


Date: Fri, 28 May 2004 15:05:00 +0200

thanxx, it works!

Regards,
P@rick

"Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@xs4all.nl> wrote in message
news:xn0dis2zm4xtpd000@msnews.microsoft.com...
> P@rick wrote:
> > I want to call a stored procedure containing a decimal parameter:
> >
> > SqlCommand dbCommand = new SqlCommand("myStoredProcedure",
myConnection);
> > dbCommand.CommandType = CommandType.StoredProcedure;
> > SqlParameter parmTOHighShort = dbCommand.Parameters.Add("@dTOHighShort",
> > SqlDbType.Decimal, 9);
>
> You didn't set the precision, you set the size to 9, but the precision is
> 12, and the scale is 9. so yo have to add:
> paramTOHighShort.Precision = 12;
> paramTOHighShort.Scale = 9;
>
> FB
>
>
>
>
> > parmTOHighShort.Direction = ParameterDirection.Input;
> > parmTOHighShort.Value = dataObject.TOHighShort;
> > try
> > {
> > dbCommand.ExecuteNonQuery();
> > }
> > catch (Exception e)
> > {
> > int i = 0;
> > }
> >
> > in the stored procedure this parameter is specified as follows:
> >
> > CREATE PROCEDURE dbo.[myStoredProcedure]( @dTOHighShort AS DECIMAL
(12,9) )
> >
> > AS
> >
> > ....
> >
> > this does not work because the SqlDBType.Decimal do not specify any
> > precision, but the T-Sql data type does!
> >
> > Do any one know how to solve this problem ?
> >
> > Regards,
> > P@rick
>
>
> --
> Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
> My .NET Blog: http://weblogs.asp.net/fbouma
> Microsoft C# MVP



Relevant Pages

  • Re: Polynomoal Regression
    ... Also some caveats regarding the importance of using precision even if a ... >> array enter into a row of two cells, or three if you want the final ... >> Regards, ... >> Peter T ...
    (microsoft.public.excel.programming)
  • Re: Low cost impedance analyzers <10MHz?
    ... > Are there any low cost impedance analyzers up to 10MHz and of around 1% ... > Regards, Joerg ...
    (sci.electronics.design)
  • Re: FDA binary Vs decimal representation
    ... If i do scaling on the filter coefficients to convert the real values ... which one is high precision representation?whether both will give same ...
    (comp.soft-sys.matlab)
  • Re: Motorola MPX4115A pressure sensor
    ... >As Martin and Tim hinted, this may be pushing a bit in regards to device ... >precision and your DVM. ...
    (sci.electronics.design)
  • Re: What is RoundToEx?
    ... You suggest we use this algorithm ... How does that compare to the one we use? ... And what are the differences regarding precision? ... Best regards ...
    (borland.public.delphi.language.basm)