欢迎光临
我们一直在努力

Asp调试存储过程

建站超值云服务器,限时71元/月

asp开发bs架构的三层系统,对于中小结构的系统把业务逻辑放在sqlserver的存储过程里面是一个很好的实现方法,但这么做出现了一个asp客户端和数据库存储过程之间配合调试的不方便.

实际开发中我写了下面一个函数,自动把asp端传给数据库的参数取出,自动生成符合sqlserver查询分析器的规则的存储过程执行命令串,放在textarea控件里,可以从页面直接复制到查询分析器里进行存储过程调试,下面就是程序.

‘==================================================================’

dim dsn ‘数据源

dim storename ‘存储过程名

dim con ‘connection对象

dim cmd ‘command对象

dim rs ‘recordset 对象

set con=server.createobject(“adodb.connection”)

con.open dsn

set cmd=server.createobject("adodb.command")

set cmd.activeconnection=con

cmd.commandtext= storename

cmd.commandtype=adcmdstoredproc

cmd.parameters.append cmd.createparameter("@state",adinteger,adparaminput,4)

cmd.parameters.append cmd.createparameter("@wheret",advarchar,adparaminput,200)

cmd.parameters.append cmd.createparameter("@branchtype",advarchar,adparaminput,50)

cmd("@state") = 1

cmd("@wheret")=”2”

cmd("@branchtype")=”3”

getpmt(cmd) ‘获取存储过程的参数

set rs=server.createobject("adodb.recordset")

rs.cursortype =3

rs.locktype =3

rs.cursorlocation =3

set rs.source =cmd

rs.open

‘======================================================’

‘ 形成存储过程的函数

‘=======================’

‘ 输入参数 a= command对象

‘=======================’

sub getpmt(a)

b=a.commandtext

b=replace(b,"?","")

b=replace(b,",","")

b=replace(b,"}","")

b=replace(b,"{","")

b=replace(b," ","")

b=replace(b,"call","")

b=replace(b,"(","")

b=replace(b,")","")

response.write "<center><table border=1 cellpadding =0 cellspacing =0 bordercolordark=#ffffff bordercolorlight=#cccc88><tr onclick="&b&".style.display=><td bgcolor=#cccc88>" & b & "</td></tr><tr id="&b&" style=display:none><td>"

response.write "<textarea rows=6 cols=70 style=font-color:#ccc888;bgcolor:#ffffc>"

response.write b

for each element in a.parameters

c=element

c="" & replace(c,"","") & ""

d=d & vbcrlf & element.name &"="& c &","

next

d=left(d,len(d)-1)

response.write d

response.write "</textarea></td></tr></table></center>"

end sub

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Asp调试存储过程
分享到: 更多 (0)

相关推荐

  • 暂无文章