List Info

Thread: Database call help




Database call help
user name
2006-09-19 14:54:17
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:dougaccessmicrosystems.net] 
Sent: Tuesday, September 19, 2006 6:08 AM
To: aspnet-databasesaspadvice.com
Subject: [aspnet-databases] RE: Database call help

Can you use sql profiler to see what is really being sent.

-----Original Message-----
    From: "Nguyen, Quanghoan T
(Hoan)"<NguyenQinhs.org>
    Sent: 9/18/06 7:11:06 PM
    To: "aspnet-databasesaspadvice.com"<aspnet-databasesaspadvice.com>
    Subject: [aspnet-databases] Database call help
    
    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
    

[Message truncated. Tap Edit->Mark for Download to get
remaining
portion.]


Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com


Need SQL Advice? http://sqladvice.com
Need RegEx Advice? http://regexadvice.com
Need XML Advice? http://xmladvice.com
Database call help
user name
2006-09-19 15:18:39
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:dougaccessmicrosystems.net] 
> 
> Can you use sql profiler to see what is really being
sent.
> 
> -----Original Message-----
>     From: "Nguyen, Quanghoan T
(Hoan)"<NguyenQinhs.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
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )