Asp調試預存程序

來源:互聯網
上載者:User
預存程序 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



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。