熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

數據庫中與C#中的數據類型對照

2022-06-13   來源: .NET編程 

  /// <summary>
  /// 數據庫中與C#中的數據類型對照
  /// </summary>
  /// <param name=type></param>
  /// <returns></returns>
  private string ChangeToCSharpType(string type)
  {
  string reval=stringEmpty;
  switch(typeToLower())
  {
  case int:
  reval= Int;
  break;
  case text:
  reval= String;
  break;
  case bigint:
  reval= Int;
  break;
  case binary:
  reval= SystemByte[];
  break;
  case bit:
  reval= Boolean;
  break;
  case char:
  reval= String;
  break;
  case datetime:
  reval= SystemDateTime;
  break;
  case decimal:
  reval= SystemDecimal;
  break;
  case float:
  reval= SystemDouble;
  break;
  case image:
  reval= SystemByte[];
  break;
  case money:
  reval= SystemDecimal;
  break;
  case nchar:
  reval= String;
  break;
  case ntext:
  reval= String;
  break;
  case numeric:
  reval= SystemDecimal;
  break;
  case nvarchar:
  reval= String;
  break;
  case real:
  reval= SystemSingle;
  break;
  case smalldatetime:
  reval= SystemDateTime;
  break;
  case smallint:
  reval= Int;
  break;
  case smallmoney:
  reval= SystemDecimal;
  break;
  case timestamp:
  reval= SystemDateTime;
  break;
  case tinyint:
  reval= SystemByte;
  break;
  case uniqueidentifier:
  reval= SystemGuid;
  break;
  case varbinary:
  reval= SystemByte[];
  break;
  case varchar:
  reval= String;
  break;
  case Variant:
  reval=Object;
  break;
  default:
  reval= String;
  break;
  }
  return reval;
  }
From:http://tw.wingwit.com/Article/program/net/201311/13236.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.