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)