在 Access 中使用“存储过程”(二)

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 sinzy 的 blog

(二)使用存储过程

然后我们可以在 asp 程序中调用这些存储过程了。

这里可以看到为什么我说 access 中的查询就是它的存储过程——我们的 command 对象的 commandtype 属性设置的是 4,即 stored proc!

so...

以下的代码很简单:

代码:
<% option explicit dim s randomize s = rnd * 100 dim conn, cmd set conn = server.createobject("adodb.connection") set cmd = server.createobject("adodb.command") conn.open "provider=microsoft.jet.oledb.4.0; data source=" & server.mappath("sp.mdb") with cmd .activeconnection = conn .commandtype = &h0004 '存储过程 .commandtext = "addnewdata" end with cmd.execute , array(cstr(now()), csng(s)) with cmd .activeconnection = conn .commandtype = &h0004 '存储过程 .commandtext = "getdata" end with dim resultrs, resultarray set resultrs = cmd.execute(, null) if not resultrs.eof then resultarray = resultrs.getrows() end if set resultrs = nothing set cmd = nothing conn.close set conn = nothing response.write "<ul>" dim i for i = 0 to ubound(resultarray, 2) response.write "<li>" & resultarray(0, i) response.write " " & resultarray(1, i) response.write " " & resultarray(2, i) response.write "</li>" next response.write "</ul>" %>

运行结果。

感觉起来,速度似乎很快,呵呵~

不知道这样在 access 中使用存储过程的意义大不大,不过确实很好玩

asp 正在没落,不过我仍然很喜欢它的小快灵~

参考资料:

http://aspalliance.com/andrewmooney/default.aspx?article=16

http://support.microsoft.com/default.aspx?scid=kb;en-us;304352

乐意和各位 asper 交流,我的 e-mail 是:sinzy@mail.biti.edu.cn 或者 ck@sinzy.net

 

本文关键:ASP Access
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top