Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decimal type initialization
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Decimal type initialization
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01563996
Message ID:
01563996
Vues:
55
Hi everybody,

I've tried to check few MSDN links, but it's still not clear to me. In our database we're using numeric(17,0) type for many Id columns - yes, I know, we should have used bigint instead to save space.

Anyway, I am wondering how should I declare it correctly in C# and how to pass correctly using ADO.NET

And also, what about CHAR(6) fields - should I use SqlDbType.Char or Varchar for parameters declaration?

Here is my current code - I appreciate some suggestions:
String tnwwSaleId = Functions.GetParameterValue(parameters, "tnWWsale_id");

                    if (!String.IsNullOrWhiteSpace(tnwwSaleId))
                    {
                        Decimal wwSaleId;
                        if (Decimal.TryParse(tnwwSaleId, out wwSaleId) && wwSaleId>0)
                        {
                            sqlBuilder.Append(" wwsale_id = @wwSaleId");
                            sqlCommand.Parameters.Add("@wwSaleId",SqlDbType.Decimal, 17).Value = wwSaleId;
                        }
                    }
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform