C# Types vs. SQL Types (kinda urgent) 
Author Message
 C# Types vs. SQL Types (kinda urgent)

Hello, friend! Consider this:

Let's say that I have an SQL Server table which contains a field of type
decimal(17,8) -- that is to say the precision is 17 and the scale is 8. I
will frequently be retrieving the contents of this field into the business
logic of a C# application, and conversely, the C# business logic will
occasionally be updating this field in SQL Server.

Now, C# does not offer a native type that is the exact equivelent of
decimal(17,8). It has a double (which could be too small), and a decimal
(which is way to large). I've decided to approach the problem from another
angle, changing the the 'type' of my SQL Server column to match that of a C#
double.... but I can't seem to find the specs for a C# double. What is the
precision? What is the scale? The MSDN .NET documentation simply states that
the precision is 15 *or*16 (which is stikes me as odd), but says nothing
about the scale.

Bottom line: How can I ensure that the C# types that I use are an exact
match for the SQL Server types that I use? With integers, it's easy. With
floating point values, I can't figure it out.

--
Fred Sanford

"To understand recursion, we must first understand recursion."



Mon, 28 Jul 2003 02:52:28 GMT  
 C# Types vs. SQL Types (kinda urgent)

Quote:
> Now, C# does not offer a native type that is the exact equivelent of
> decimal(17,8).

Decimal should work, but SQLNumeric is meant to be the exact match.

Quote:
> With
> floating point values, I can't figure it out.

For floating points, try SQLSingle and SQLDouble. They are in Data.SQLTypes.

--
Jonathan Allen



Mon, 28 Jul 2003 04:58:01 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. C# Base Types vs. .NET Types

2. SQL timestamp data type - correspondency with c++ data type

3. undefined type in arg list vs. return type

4. type *var -- vs. -- type* var

5. value types vs. reference types

6. Type Casting between Base and Derived Type (Serialization of objects with Type members)

7. Variables and types of type "Type"

8. Stack/Heap Monitor? (kinda urgent)

9. Incomplete type error (URGENT)

10. Urgent: VARIANT type

11. Urgent.......Please See Regarding the registration of file types

12. Urgent: VARIANT type

 

 
Powered by phpBB® Forum Software