Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

how to map datatypes...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
light_wt - 15 Nov 2006 03:25 GMT
The MS SQL has a column using DEC(11) which is an unsignedInt.

What is the correct way to declare the unsignedInt variable in c# to insert
this value to MS SQL?

recall from SQL2k BOL
Use the int data type to store numbers in the range from -2,147,483,648
through 2,147,483,647 only (requires 4 bytes of storage per value).

What I like to do is use the entire range as a positive value.

Thanks.
Charles Calvert - 15 Nov 2006 04:19 GMT
>The MS SQL has a column using DEC(11) which is an unsignedInt.
>
>What is the correct way to declare the unsignedInt variable in c# to insert
>this value to MS SQL?

2 bytes: UInt16
4 bytes: UInt32
8 bytes: UInt64

Note that these types are not CLS-compliant.
Signature

Charles Calvert             |  Software Design/Development
Celtic Wolf, Inc.           |  Project Management
http://www.celticwolf.com/  |  Technical Writing
(703) 580-0210              |  Research

Dave Sexton - 15 Nov 2006 09:15 GMT
Hi,

In Sql Server, "dec" is an alias for the "decimal" data type.  Dec(11)
represents a signed, numeric data type with a precision of 11 and no scale,
meaning that there can be no digits to the right side of the decimal.

According to the docs, a precision of 11 requires 9 bytes:

"decimal and numeric (Transact-SQL)"
http://msdn2.microsoft.com/en-us/library/ms187746.aspx

To maximize the capacity of values in managed code and to retain the sign of
the number, you must use System.Decimal, which is the only primitive structure
capable of representing all possible values of dec(11), AFAIK.

Signature

Dave Sexton

> The MS SQL has a column using DEC(11) which is an unsignedInt.
>
[quoted text clipped - 8 lines]
>
> Thanks.
light_wt - 15 Nov 2006 18:18 GMT
Thank you both of you.

Yes, Dave.  I am going to try using system.decimal in c# to
represent/passing dec(11) in ms sql.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.