Serial number |
Category |
Sql server |
C Sharp |
Note |
1 |
Integer |
Bit |
Boolean |
True to convert to 1False to 0 |
2 |
tinyint |
Byte |
C sharp data types are located in the System namespace |
3 |
smallint |
Int16 |
4 |
Int |
Int32 |
5 |
bigint |
Int64 |
6 |
SmallMoney |
Decimal |
7 |
Money |
Decimal |
8 |
Numeric |
Decimal |
9 |
Decimal |
Decimal |
10 |
Floating point number |
Float |
Double |
11 |
Real |
Single |
12 |
Date and time |
smalldatetime |
Datetime |
13 |
Datetime |
Datetime |
14 |
Timestamp |
Datetime |
15 |
String |
Char |
String |
16 |
Text |
String |
17 |
varchar |
String |
18 |
NChar |
String |
19 |
ntext |
String |
20 |
nvarchar |
String |
21st |
Binary data |
Binary |
Byte[] |
22 |
varbinary |
Byte[] |
23 |
Image |
Byte[] |
24 |
Other |
uniqueidentifier |
Guid |
25 |
Variant |
Object |
PS. Originally intended to reprint trackback:http://tb.blog.csdn.net/trackback.aspx?postid=95675 (SQL Server corresponds to the data type in C #, but feels that the author writes it in code, looks less intuitive, and is inconvenient to find. Therefore, the author's article and SQLServer05 's help document make the above table.
trackback:http://tb.blog.csdn.net/trackback.aspx?postid=1288946
<summary>
Comparison of data types in the database with 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;
}
SQL Server and C # data type correspondence table