C # operate SQL float data. In C #, it is OK to use the double type. C # compare the data type with the SQL data type.

Source: Internet
Author: User

C # the SQL float type is operated, and the data will contain many decimal places. Originally, the float type of C # is different from the float type of SQL.

/// <Summary>
/// Compare the data types in the database with those in C #
/// </Summary>
/// <Param name = "type"> </param>
/// <Returns> </returns>
Private string changetocsharptype (string type)
{
String reval = string. empty;
Switch (type. tolower ())
{
Case "int ":
Reval = "int32 ";
Break;
Case "text ":
Reval = "string ";
Break;
Case "bigint ":
Reval = "int64 ";
Break;
Case "binary ":
Reval = "system. byte []";
Break;
Case "bit ":
Reval = "Boolean ";
Break;
Case "char ":
Reval = "string ";
Break;
Case "datetime ":
Reval = "system. datetime ";
Break;
Case "decimal ":
Reval = "system. Decimal ";
Break;
Case "float ":
Reval = "system. Double ";
Break;
Case "image ":
Reval = "system. byte []";
Break;
Case "money ":
Reval = "system. Decimal ";
Break;
Case "nchar ":
Reval = "string ";
Break;
Case "ntext ":
Reval = "string ";
Break;
Case "numeric ":
Reval = "system. Decimal ";
Break;
Case "nvarchar ":
Reval = "string ";
Break;
Case "real ":
Reval = "system. Single ";
Break;
Case "smalldatetime ":
Reval = "system. datetime ";
Break;
Case "smallint ":
Reval = "int16 ";
Break;
Case "smallmoney ":
Reval = "system. Decimal ";
Break;
Case "timestamp ":
Reval = "system. datetime ";
Break;
Case "tinyint ":
Reval = "system. Byte ";
Break;
Case "uniqueidentifier ":
Reval = "system. guid ";
Break;
Case "varbinary ":
Reval = "system. byte []";
Break;
Case "varchar ":
Reval = "string ";
Break;
Case "variant ":
Reval = "object ";
Break;
Default:
Reval = "string ";
Break;
}
Return reval;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.