sql-C#-类型对应

bitbool
tinyintbyte
smallintshort
intint
bigintlong
realfloat
floatdouble
moneydecimal
datetimeDateTime
charstring
varcharstring
ncharstring
nvarcharstring
textstring
ntextstring
imagebyte[]
binarybyte[]
uniqueidentifierGuid



















/ 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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/407885.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

关于局部变量在内存中的地址

C code: #include<stdio.h> void main(){ int aa 11, bb 22; int a 1; int b 2; printf("%X/t%X/t%X/t%X/n", &aa, &bb, &a, &b);} Running Result: 12FF7C 12FF78 12FF74 12FF70 可见局部变量是存放在栈区的&#xff0c;他们的地址先…

C++20 Atomic 原子 内存模型(二)

C20 Atomic 原子 内存模型(二) 原子是C内存模型的基础 强/弱内存模型 1. 强内存模型 Leslie Lamport 定义了顺序一致性的概念 顺序一致性提供两个保证: 指令按源码的顺序执行对所有线程的所有指令有全局的顺序 以上不仅仅作用于原子, 也影响着非原子变量 int main(int a…

认证考试介绍之RHCE篇

认证考试介绍之RHCE篇 RHCE是Red Hat Certified Engineer的简称&#xff0c;始于1999年3月。截至2001年1月17日&#xff0c;Red Hat的统计资料表明&#xff0c;RHCE资格认证的通过率为62.5%。RHCE是市场上第一个面向Linux的认证考试&#xff0c;它不是一个普通的认证测试&#…

jquery 操作服务端控件,select 控件

<asp:DropDownList ID"ddl" runat"server"></asp:DropDownList> <select id"ddlsel" ></select> jquery取得该控件的方式有&#xff1a; 1. var ddl $("#<%ddl.ClientID%>"); //jq获取服务端控件,此方…

C++ 20 线程安全的Map

C 20 线程安全的Map 粗粒度(锁住整个bucket_data) template <typename Key, typename Value, typename Hash std::hash<Key>> class threadsafe_lookup_table { private:class bucket_type{private:using bucket_value std::pair<Key, Value>;using buck…

毕业多年,我们转变了多少?

懵懂,激情,成熟,沉默.似乎就是每个人的必经之路.从毕业时的酬躇满志到如今的随遇而安,从毕业时的悲伤离别到如今的陌路行人.从毕业时的海枯石烂到如今的两情分别.究竟,我们还有多少没有转变?毕业两年了,才知道,理想再崇高,究竟还是比不过面包.没有理想,大家照样活的滋润.没有面…

IOS设计模式之二(门面模式,装饰器模式)

本文原文请见&#xff1a;http://www.raywenderlich.com/46988/ios-design-patterns.由 krq_tiger&#xff08;http://weibo.com/xmuzyq&#xff09;翻译&#xff0c;如果你发现有什么错误&#xff0c;请与我联系谢谢。门面&#xff08;Facade&#xff09;模式&#xff08;译者…

java实现输出字符串中的数字字符

package com.joe; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test { //将字符串的数字字符输出 public static void main(String[] args) { String str "iu7i8hy4jnb2"; //方法一 …

隐私策略 URL

本隐私策略的目的是说明当您访问和使用本插件时我们可能会搜集的资料, 我们会怎样使用这些资料, 是否会透露给第三方, 以及您对这些资料的使用及修改方面的选择权利. 本隐私策略适用于本插件,您需要仔细阅读本隐私策略. 访问者的信息 本插件会保存用户要求保存的信息 插件将…

揭开Vmware 虚拟软件层的秘密

【电脑商网专稿】虚拟软件究竟是什么软件, 是让所有的软件都”虚拟”执行吗, 虚拟软件层究竟是怎样的一层软件? 为什么现在这么多的公司和个人都在使用这种软件, 虚拟软件能代替操作系统完全控制硬件吗? 下面就让我们逐渐的揭开虚拟化技术这一特殊软件层的秘密吧.谈到虚拟化就…

1.使用 Blazor 利用 ASP.NET Core 生成第一个 Web 应用

参考 https://dotnet.microsoft.com/zh-cn/learn/aspnet/blazor-tutorial/create 1.使用vs2022创建新项目 选择 C# -> Windows -> Blzxor Server 应用模板 2.项目名称BlazorApp下一步 3.选择 .NET6.0 或 .NET7.0 或 .NET8.0 创建 4.运行BlazorApp 5.全部选择是。 信…

BROCADE 300和MD3200扩展柜FC SAN,截图

这表示俺玩过&#xff0c;其实&#xff0c;这个光交换机在只有一个共享存储的情况下&#xff0c;可用可不用。 FC BROCADE只是为了方便后期扩展。 FC SAN之类的识别不靠IP&#xff0c;因为不是IP SAN嘛。但也是自己的识别体系。 转载于:https://www.cnblogs.com/aguncn/p/36640…

Java从控制台中读取数据完全攻略

0 引言从控制台中读取数据是一个比较常用的功能&#xff0c;在 JDK 5.0 以前的版本中的实现是比较复杂的&#xff0c;需要手工处理系统的输入流。有意思的是&#xff0c;从 JDK 5.0 版本开始&#xff0c;能从控制台中输入数据的方法每增加一个版本号&#xff0c;就有一种新增的…

总算有点眉目了!

今天打开一个很久没用的邮箱~发现51CTO居然还记得我给我发了封邮件~我也很久没去了&#xff08;基本上注册过后就没去&#xff09;进去看了下~发现变化好大......壮大了。现在我有点激动&#xff0c;总算找到点眉目&#xff0c;在经过了2年的等死阶段&#xff08;偶于2005年学校…

C++ 20 并发编程 std::promise

C 20 并发编程 std::promise std::promise和std::future是一对, 通过它们可以进行更加灵活的任务控制 promise通过函数set_value()传入一个值, 异常, 或者通知, 并异步的获取结果 例子: void product(std::promise<int>&& intPromise, int a, int b) {intPro…

react(87)--批量删除进行置空操作

if (selectedRowKeysList.length 0) {message.error(请选中列表内容);}this.setState({selectedRowKeysList: [],});