Code
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;
}
This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/kong521/archive/2008/10/23/3132069.aspx