hi,
for a 'total cost' field in sql i used the data type 'money'.. in c# what data type should i use to match that of the sql?? decimal or float??
thanks
hi,
for a 'total cost' field in sql i used the data type 'money'.. in c# what data type should i use to match that of the sql?? decimal or float??
thanks
Pls, give us an example. So, that we can provide any help to u.
in the database using sql:
tblReservation fields:
-> TotalCost - money (dataType)
------------------------------------------------
C# class:
public class Reservation
{
float TotalCost;
}
OR
public class Reservation
{
decimal TotalCost;
}
The most suitable dataType for these type of comparisons is string as the retrieved data is in String form. If you want to perform any calculation with totalCost you can temporarily convert it to double(not float or decimal it is much more flexible than the other two) and again store the result in a string. but as far as comparison is concerned use string instead of float or decimal.
The most suitable dataType for these type of comparisons is string as the retrieved data is in String form.
This is contrary to what Microsoft says. According to the SQL data types to CLR data mapping money is a decimal type.
Also using strings to compare numbers is a bad idea at best. Using strings which of these values is larger 11 or 2?
This is contrary to what Microsoft says. According to the SQL data types to CLR data mapping money is a decimal type.
Also using strings to compare numbers is a bad idea at best. Using strings which of these values is larger 11 or 2?
thats how i think as well.. so should i use double with money or decimal ? since in sql i'm using money and i don't know what to use in c# to match
Always use decimal when doing calculations with money. It doesn't have the rounding problems that double or float will have.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.