bit bool
tinyint byte
smallint short
int int
bigint long
real float
float double
money decimal
datetime DateTime
char string
varchar string
nchar string
nvarchar string
text string
ntext string
image byte[]
binary byte[]
uniqueidentifier Guid

/ SqlDbType转换为C#数据类型
public static Type SqlType2CsharpType(SqlDbType sqlType){switch (sqlType){case SqlDbType.BigInt:return typeof(Int64);case SqlDbType.Binary:return typeof(Object);case SqlDbType.Bit:return typeof(Boolean);case SqlDbType.Char:return typeof(String);case SqlDbType.DateTime:return typeof(DateTime);case SqlDbType.Decimal:return typeof(Decimal);case SqlDbType.Float:return typeof(Double);case SqlDbType.Image:return typeof(Object);case SqlDbType.Int:return typeof(Int32);case SqlDbType.Money:return typeof(Decimal);case SqlDbType.NChar:return typeof(String);case SqlDbType.NText:return typeof(String);case SqlDbType.NVarChar:return typeof(String);case SqlDbType.Real:return typeof(Single);case SqlDbType.SmallDateTime:return typeof(DateTime);case SqlDbType.SmallInt:return typeof(Int16);case SqlDbType.SmallMoney:return typeof(Decimal);case SqlDbType.Text:return typeof(String);case SqlDbType.Timestamp:return typeof(Object);case SqlDbType.TinyInt:return typeof(Byte);case SqlDbType.Udt://自定义的数据类型return typeof(Object);case SqlDbType.UniqueIdentifier:return typeof(Object);case SqlDbType.VarBinary:return typeof(Object);case SqlDbType.VarChar:return typeof(String);case SqlDbType.Variant:return typeof(Object);case SqlDbType.Xml:return typeof(Object);default:return null;}}
复制内容到剪贴板
代码:
// sql server数据类型(如:varchar)
// 转换为SqlDbType类型
public static SqlDbType SqlTypeString2SqlType(string sqlTypeString){SqlDbType dbType = SqlDbType.Variant;//默认为Objectswitch (sqlTypeString){case "int":dbType = SqlDbType.Int;break;case "varchar":dbType = SqlDbType.VarChar;break;case "bit":dbType = SqlDbType.Bit;break;case "datetime":dbType = SqlDbType.DateTime;break;case "decimal":dbType = SqlDbType.Decimal;break;case "float":dbType = SqlDbType.Float;break;case "image":dbType = SqlDbType.Image;break;case "money":dbType = SqlDbType.Money;break;case "ntext":dbType = SqlDbType.NText;break;case "nvarchar":dbType = SqlDbType.NVarChar;break;case "smalldatetime":dbType = SqlDbType.SmallDateTime;break;case "smallint":dbType = SqlDbType.SmallInt;break;case "text":dbType = SqlDbType.Text;break;case "bigint":dbType = SqlDbType.BigInt;break;case "binary":dbType = SqlDbType.Binary;break;case "char":dbType = SqlDbType.Char;break;case "nchar":dbType = SqlDbType.NChar;break;case "numeric":dbType = SqlDbType.Decimal;break;case "real":dbType = SqlDbType.Real;break;case "smallmoney":dbType = SqlDbType.SmallMoney;break;case "sql_variant":dbType = SqlDbType.Variant;break;case "timestamp":dbType = SqlDbType.Timestamp;break;case "tinyint":dbType = SqlDbType.TinyInt;break;case "uniqueidentifier":dbType = SqlDbType.UniqueIdentifier;break;case "varbinary":dbType = SqlDbType.VarBinary;break;case "xml":dbType = SqlDbType.Xml;break;}return dbType;}
复制内容到剪贴板
代码:// sql server中的数据类型,转换为C#中的类型类型
public static Type SqlTypeString2CsharpType(string sqlTypeString){SqlDbType dbTpe = SqlTypeString2SqlType(sqlTypeString);return SqlType2CsharpType(dbTpe);}// 将sql server中的数据类型,转化为C#中的类型的字符串
public static string SqlTypeString2CsharpTypeString(string sqlTypeString){Type type = SqlTypeString2CsharpType(sqlTypeString);return type.Name;}

转载于:https://www.cnblogs.com/lonelyofsoul/p/3655932.html

sql-C#-类型对应相关推荐

  1. PL/SQL集合类型的整理学习

    http://log-cd.iteye.com/blog/521177 PL/SQL集合类型是类似于高级语言数组的一种复合数据类型,集合类型包括索引表(PL/SQL表).嵌套表(Nested Tabl ...

  2. 数据库SQL语言类型(DQL.DML.DDL.DCL)

    1.SQL语言 SQL(Structure Query Language)语言是数据库的核心语言. SQL是一个标准的数据库语言, 是面向集合的描述性非过程化语言. 它功能强,效率高,简单易学易维护. ...

  3. SQL SERVER类型与C#类型对照

      SQL SERVER类型   C#类型 精确数字 bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807) 的整型数 ...

  4. SQL注入:SQL注入类型(手动)SQL注入的检测

    一.SQL注入流程 1.判断是否有SQL注入漏洞(检测) 2.判断操作系统.数据库和web应用类型 3.获取数据库信息,包括管理员信息及拖库 4.加密信息破解,sqlmap可自动破解 5.提升权限,获 ...

  5. 常见的SQL注入类型

    一.SQL注入原理 SQL注入简单原理 * 二.常见的SQL注入类型 注:?为php语言中的输入符 (1).按注入点区分: 1.数字型注入 数字型注入主要存在于网站的url中有?id=处,如:http ...

  6. 第十章 PL/SQL对象类型

    第十章 PL/SQL对象类型 一.抽象的角色 抽象是对一个真实世界实体的高级描述或建模.它能排除掉无关的细节内容,使我们的日常生活更有条理.例如,驾驶一辆汽车时,我们是不需要知道它的发 动机是如何工作 ...

  7. 第十章 PL/SQL对象类型 ( 1 )

    第十章 PL/SQL对象类型 一.抽象的角色 抽象是对一个真实世界实体的高级描述或建模.它能排除掉无关的细节内容,使我们的日常生活更有条理.例如,驾驶一辆汽车时,我们是不需要知道它的发动机是如何工作的 ...

  8. idea设置识别.sql文件类型以及其他文件类型

    idea设置识别.sql文件类型 今天莫名其妙尝试安装某个插件,结果卸载完后,.sql文件无法识别了,不能像之前那样运行. 解决方法: 依次点击setting-->Editor-->Fil ...

  9. 关于sql弱类型语言的绕过

    sql语言是弱类型语言,今天根据这个特性做了个小测试 在sql语句里"="是判断的意思,并不是赋值. 根据上图,**'1test'**这是一个字符窜,而他第一个字符是1,就类似于M ...

  10. oracle模糊匹配date类型日期,SQL时间类型模糊查询

    SQL时间类型模糊查询 数据库类型为DateTime类型,将其做模糊查询时,在Hibernate中,可以用拼SQL的问题将其解决,即在SQL查询分析器写SQL一样,但是利用参数配置,则方法如下: 1. ...

最新文章

  1. Python必须要掌握的高端语法
  2. 甘肃黄土山地数十载现“满眼绿” 护林员四季不歇护植被
  3. stm32使用rtc到底用LSI还是LSE
  4. 单图说TDSQL;OceanBase 2.2 事务引擎核心功能;穿云箭2.0版发布;RMAN DUPLICATE配置19C DG;外键上有无索引的影响;MySQL8.0 索引新功能;GaussDB C
  5. MQ监听 linux,RabbitMQ的安装,配置,监控
  6. 快速实现python c扩展模块
  7. 基础设置---python库--matplotlib
  8. struts2中的action获取web资源
  9. 解决VMware重启IP地址改变的问题
  10. 用Java编写考试报名系统_基于jsp的计算机考试报名系统-JavaEE实现计算机考试报名系统 - java项目源码...
  11. ps怎么撤销参考线_ps打开辅助线的快捷键在哪,ps如何取消辅助线
  12. 无法连接数据库2003-cant connect to Mysql server on ‘localhost’(10038)
  13. 《设计心理学》学习笔记之日常的设计(第一册)
  14. 田忌赛马(贪心算法)
  15. JavaFX应用程序图标
  16. Exchange邮箱的创建和配置
  17. 计算机老师三年发展规划,信息技术专业教师个人发展三年规划汇总(全).doc
  18. hdu2907 凸包+简单搜索
  19. Linux读取群晖文件,debian读取群晖硬盘
  20. 英文文本关键词抽取——使用NLTK进行关键词抽取

热门文章

  1. .NEt中的继承、聚合和组合
  2. 物理机实时监控UI之grafana(SimpleJson)+gRPC
  3. linux下elasticsearch的安装
  4. oh-my-zsh官方教程
  5. 匹配字符串-好技能-正则表达式
  6. 如何用 Python 实现 Web 抓取?
  7. MySQL 读写分离 使用驱动com.mysql.jdbc.ReplicationDriver
  8. 报告显示Q2 Android平板电脑全球市场份额达67%
  9. 在应用程序级别以外使用注册为 allowDefinition='MachineToApplication' 的节是错误
  10. 文件的删除和文件信息的读取