Hoan,
There are three things you need to check. First, the
destination column in the table in the database. What is
the actual datatype,
with the precision and scale? You need all three
characteristics. Now, let's assume that you have
decimal(7, 3) [which means that
you can have numbers with the positions: 1234.567 or in the
range from .001 to 9999.999]. Now, how is the stored
procedure's
parameter defined? It should be the same or of greater
precision/scale. Now, the SqlParameter you have listed
below...it needs to
be defined like the parameter in the stored procedure. So,
you would need
SqlParameter prmScore = cmdSql.Parameters.Add(" Score", SqlDbType.Decimal);
prmScore.Precision = 7;
prmScore.Scale = 3;
prmScore.Value = Convert.ToDecimal(strScore);
hth,
David
Nguyen, Quanghoan T (Hoan) wrote:
> I cannot use Profiler, since I am not a part of the SQL
Admin group.
> Unfortunately, we are locked down pretty tight.
>
> Hoan Nguyen
>
> -----Original Message-----
> From: Douglas Reilly [mailto:doug accessmicrosystems.net]
>
> Can you use sql profiler to see what is really being
sent.
>
> -----Original Message-----
> From: "Nguyen, Quanghoan T
(Hoan)"<NguyenQ inhs.org>
>
> Hello all,
>
>
>
> I am maintaining a VS 2003 native application,
written in C# by
> someone
> else. There is a database table that contains many
fields of type
> (numeric). The data I get from the user looks like
(84.0002), and
> when
> I call my stored proc, it executes and returns a
value of 1 but the
> database field was never changed. I'm using the
SqlDbType.Decimal
> to
> define the parameter type and doing a
Convert.ToDecimal(strScore) :
>
>
>
> cmdSql.Parameters.Add(" Score", SqlDbType.Decimal).Value
> =
> Convert.ToDecimal(strScore);
>
>
>
> Is this parameter type correct? I don't seem to
get any exceptions
> when
> I run the code, except that I don't seem to see
the change in the
> database table. If I use Query Analyser to execute
the stored proc
> and
> pass in the numbers (84.0002, 85.0006 ...),
everything gets updated
> fine. That's why I'm not sure if my conversions
are correct. Any
> help
> would be great.
>
>
>
> Thank You,
>
>
>
> Hoan Nguyen
Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
|