ASP Debug Stored Procedures

Source: Internet
Author: User
Tags dsn sql server query
The storage procedure ASP develops the BS architecture three layer system, for the small and medium structure system puts the business logic in the SQL Server's stored procedure to be a very good realization method, but does this has the inconvenience which the ASP client and the database stored procedure is coordinated between debugging.

In the actual development I wrote the following function, automatically send the ASP end to the database parameters out, automatically generate the SQL Server Query Analyzer rules of the Stored procedure execution command string, placed in the textarea control, can be copied from the page directly to the Query Analyzer for stored procedure debugging, Here is the program.
' ================================================================== '
Dim DSN ' Data Source
Dim storename ' Stored Procedure name
Dim con ' Connection Object
Dim cmd ' Command Object
Dim rs ' Recordset Object
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) ' Gets the parameters of the stored procedure
Set Rs=server. CreateObject ("Adodb.recordset")
Rs. CursorType =3
Rs. LockType =3
Rs. CursorLocation =3
Set Rs. Source =cmd
Rs. Open
' ====================================================== '
' Functions that form stored procedures
' ======================= '
' Input parameter a= command object
' ======================= '
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



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.