A double type is required in a C # project to manipulate the MSSQL float type data (with C # data type and SQL data type Control)

Source: Internet
Author: User

C # Operations SQL float type, the data will be many decimals, originally C # Float and SQL float type inconsistent. The following is a comparison of data types in the database and in C #.

        /// <summary>        ///Comparison of data types in the database with C #/// </summary>        /// <param name= "type" ></param>        /// <returns></returns>        Private stringChangetocsharptype (stringtype) {            stringReval =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; }            returnReval; }

Comparison of data types in the database with C #

A double type is required in a C # project to manipulate the MSSQL float type data (with C # data type and SQL data type Control)

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.