Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Decimal type initialization
Message
 
 
À
25/01/2013 04:00:14
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01563996
Message ID:
01564041
Vues:
27
>>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 always 6 char and, since char in .net is a unicode value wouldn't nchar(6) be the logical choice ?

The database already exists and we're not going to change it. My question is how to properly define parameters for decimal (17,0) and char(6) ? Is what I am showing above correct?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform