天天看點

SQL Serve和C# 資料類型之間的轉換

 public string changedbtypetocsharptype(string type)

      {

       string reval=string.empty;

       switch(type.tolower())

       {

        case "int":

         reval= "int";

         break;

        case "text":

         reval= "string";

        case "bigint":

         reval= "long";

        case "binary":

         reval= "object";

        case "bit":

         reval= "bool";

        case "char":

        case "datetime":

         reval= "datetime";

        case "decimal":

         reval= "decimal";

        case "float":

         reval= "double";

        case "image":

         reval= "byte[]";

        case "money":

        case "nchar":

        case "ntext":

        case "numeric":

        case "nvarchar":

        case "real":

         reval= "float";

        case "smalldatetime":

        case "smallint":

         reval= "short";

        case "smallmoney":

        case "timestamp":

         reval= "system.datetime";

        case "tinyint":

        case "uniqueidentifier":

         reval= "guid";

        case "varbinary":

        case "varchar":

        case "variant":

         reval="object";

        default:

       }

       return reval;

      }