>>>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?
The decimal looks OK to me (but don't take my word for it :-})
I'm not sure about char. In .NET char is a two-byte structure whereas (I think? ) char in SQL is one byte. I've no idea how well those play together....