软件下载 | 资讯教程 | 最近更新 | 下载排行 | 一键转帖 | 发布投稿
您的位置:最火下载站 > 网络编程 > ASP教程 > 模仿jQuery的链式操作来执行ADODB.Command

模仿jQuery的链式操作来执行ADODB.Command

Command对象的参数属性太多,于是这个蛋疼产物就诞生了

<!--#include file="core/inc.asp"--><%
dim cmd, sql, rs, rc
set cmd = new SqlCommand
sql = "select UserID,Email from zgx_Users where UserID < ? and Activation = ?"
cmd.c(DB.Conn(0)).t(1).tx(sql).i("UserID", 3, 4, 3).i("Activation", 11, 1, 1).e(rs, rc).f()
printl(rc)
printl(rs.eof)
do while not rs.eof
    printl rs("UserID") & " - " & rs("Email")
    rs.Movenext()
loop
%>

<%
class SqlCommand
private p_cmd

private sub class_initialize
set p_cmd = Server.CreateObject("ADODB.Command")
end sub

private sub class_terminate
set p_cmd = nothing
end sub
public function Conn(conn_)
set p_cmd.ActiveConnection = conn_
set Conn = me
end function
public function SetType(val_)
p_cmd.CommandType = val_
set SetType = me
end function

public function Text(txt_)
p_cmd.CommandText = txt_
set Text = me
end function
public function Append(name_, dtype_, dir_, len_, value_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, dtype_, dir_, len_, value_)
set Append = me
end function
public function Input(name_, dtype_, len_, value_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, dtype_, 1, len_, value_)
set Input = me
end function

public function Output(name_, dtype_, len_, value_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, dtype_, 2, len_, value_)
set Output = me
end function

public function Return(name_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, 3, 4)
set Return = me
end function
public function Exec(byref rs_, byref rowAffected_)
set rs_ = p_cmd.Execute(rowAffected_)
set Exec = me
end function
public function GetValue(byval name_, byref val_)
val_ = p_cmd(name_)
set GetValue = me
end function
public function Finish()
set Finish = me
end function

'----------------------------------------

public function C(conn_)
set p_cmd.ActiveConnection = conn_
set C = me
end function

public function T(val_)
p_cmd.CommandType = val_
set T = me
end function

public function Tx(txt_)
p_cmd.CommandText = txt_
set Tx = me
end function

public function A(name_, dtype_, dir_, len_, value_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, dtype_, dir_, len_, value_)
set A = me
end function

public function I(name_, dtype_, len_, value_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, dtype_, 1, len_, value_)
set I = me
end function
public function E(byref rs_, byref rowAffected_)
set rs_ = p_cmd.Execute(rowAffected_)
set E = me
end function
public function O(name_, dtype_, len_, value_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, dtype_, 2, len_, value_)
set O = me
end function
public function R(name_)
p_cmd.Parameters.Append p_cmd.CreateParameter(name_, 3, 4)
set R = me
end function
public function G(byval name_, byref val_)
val_ = p_cmd(name_)
set G = me
end function
public function F()
set F = me
end function
end class
%>

    相关阅读
    栏目导航
    推荐软件