commandtype.text有什么用? [英] What is the use of commandtype.text?

查看:121
本文介绍了commandtype.text有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CommandType.Text有什么用?



是否需要使用cmd.CommandType = CommandType.Text;



我尝试过:



cmd.CommandType = CommandType.Text;

what is the use of "CommandType.Text?"

Is it necessary to use the cmd.CommandType = CommandType.Text;

What I have tried:

cmd.CommandType = CommandType.Text;

推荐答案

当命令是原始SQL时使用Text命令类型,例如从表中选择字段,其中id = 1。这是CommandType的默认值,因此如果您的命令确实是sql,那么您不需要将CommandType设置为文本,但为了清晰起见,它可能更好(如果它们更改了默认值)。如果您想将命令设置为存储过程或表的名称,则必须指定正确的CommandType。
The Text commandtype is used when the command is raw SQL, like "select field from table where id=1". This is the default value of CommandType so if your command is indeed sql then you don't need to set CommandType to text, but it's probably better that you do for clarity (and in case they change the default). If you wwant to set the command to the name of a Stored Procedure or table then you have to specify the correct CommandType.


Simple。 CommandType [ ^ ]表示或指定如何解释 CommandText 属性。

CommandType Enumeration [ ^ ]

StoredProcedure - 存储过程的名称。

TableDirect - 表的名称。 />
文本 - 一个SQL文本命令。 (默认。)



Cocnlusion:当你想要执行 CommandType.Text href =https://msdn.microsoft.com/en-us/library/ms978509.aspx> CRUD [ ^ ]操作。



这就是全部!
Simple. CommandType[^] indicates or specifies how the CommandText property is interpreted.
There are 4 members of CommandType Enumeration[^]
StoredProcedure - The name of a stored procedure.
TableDirect - The name of a table.
Text - An SQL text command. (Default.)

Cocnlusion: you should use CommandType.Text when you want to execute one of CRUD[^] operation.

That's all!


这篇关于commandtype.text有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆