cndaliu.com
专注于技术,切不可沉湎于技术
<2009年1月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

文章分类

友情链接

SQL Server与C#中数据类型的对应关系

类别:数据库 - Sql Server   时间:2008-8-14 11:43:30   点击:294   标签:SQL C# 数据类型 对应关系

SQL Server与C#中数据类型的对应关系

/// <summary>

/// 数据库中与c#中的数据类型对照.

/// </summary>

/// <param >SQL Server中的数据类型。</param>

/// <returns>返回C#中对应的数据类型。</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;

}

相关文章


发表评论


  • 姓名:
  • 评论:
  •          
Copyright © cndaliu.com 2007-2010, Powered by 52DotNet.com 苏ICP备07506889号