演示了command的使用。另外还有设置参数,防止注入,不太明白。
http://blog.youkuaiyun.com/kj021320/article/details/1689960
通常为了省事 程序员都喜欢直接采用Connection的execute方法,SQL是拼凑出来的!当然很容易出现问题了~~而很多人都知道 Command可以用来执行存储过程
其实Command 直接执行SQL性能效率更好,而且更安全,有点像JAVA里面的PreparedStatement 同构的SQL语句.....
以下我建立了一个ACCESS的数据库叫 kj021320.mdb
其中有一个表 nonamed 字段 name 文本类型 class 数字类型
OK 手工往表里面插入2条数据
name class
aaa' 1
b'b 2
下面来看看command CommandType的枚举值代表的意思~我们将用到 adCmdText
CommandTypeEnum Values
Constant
常量
Value
值
Description
描述
adCmdUnspecified
-1
Does not specify the command type argument.
不指定指令类型自变量
adCmdText
1
Evaluates CommandText as a textual definition of a command or stored procedur