• SQL SERVER与C#的数据类型对应表


    序号
    类别
    SQLServer
    C Sharp
    备注
    1
    整数
    bit
    Boolean
    True转换为1False转换为0
    2
    tinyint
    Byte
    C Sharp 数据类型都位于System命名空间
    3
    smallint
    Int16
    4
    int
    Int32
    5
    bigint
    Int64
    6
    smallmoney
    Decimal
    7
    money
    Decimal
    8
    numeric
    Decimal
    9
    decimal
    Decimal
    10
    浮点数
    float
    Double
    11
    real
    Single
    12
    日期和时间
    smalldatetime
    DateTime
    13
    datetime
    DateTime
    14
    timestamp
    DateTime
    15
    字符串
    char
    String
    16
    text
    String
    17
    varchar
    String
    18
    nchar
    String
    19
    ntext
    String
    20
    nvarchar
    String
    21
    二进制数据
     
     
    binary
    Byte[]
    22
    varbinary
    Byte[]
    23
    image
    Byte[]
    24
    其他
    uniqueidentifier
    Guid
    25
    Variant
    Object
    /// <summary>
    /// 数据库中与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中如何用一个表的列更新另一个表的列?
    ASPxGridView利用CheckBox实现全选
    DevExpress.NETv8.1(Web Controls)学习笔记
    ALSA vs OSS
    video telephone
    uClinux系统分析 转
    Using KVM On Ubuntu 7.10 (Gutsy Gibbon)转
    想买开发板,我真的需要么?
    uClinux的内存管理转
    各种开源软件授权方式的选择 (zt)
  • 原文地址:https://www.cnblogs.com/leiOOlei/p/1956119.html
Copyright © 2020-2023  润新知