Advertisement

01.16.2008 at 10:23AM PST, ID: 23087876
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Execute Stored Procedure within ASP Page

Asked by SasDev in Active Server Pages (ASP)

Tags: ,

Question: I have a stored procedure that I would like executed within an existing asp page ("UpdatePurchaseOrdersCPY3") cmdstoredproc11. The sp updates the deptID within the PurchaseOrders table to reflect a deptID number associated with a persons employeenum. The cmdstoredproc11 statement I added is close to the bottom of the asp sample.
The sp will use existing connection settings from the asp (conn1). I am not an asp programmer and I am trying to get the correct syntax as to how to execute the sp correctly within the particular page. I want to have it execute below the sp "UpdatePurchaseOrdersCPY" because I want my new inserted sp to update only after the "ponum" has been updated within the sql table. The syntax I have created for the new sp I'm sure is inaccurate. I am trying to go along the lines of how the other sp's were created and executed within the asp. ASP is not easy for me to follow, so any help would be greatly appreciated.


ASP Connection within opendb.asp:
<%
Set conn1 = Server.CreateObject("ADODB.Connection")
conn1.Open "Provider=SQLOLEDB; Data Source=SQL-VS01-PROD; Initial Catalog=PurchaseOrders; User ID=*; Password= *"
%>


SQL Stored Procedure:

USE PURCHASEORDERS
ALTER PROCEDURE [dbo].[UpdatePurchaseOrdersCPY3]

      @intPONum      AS      int

AS

update tblpurchaseorders
set deptID = (select cast(a.department as int)
                          from sascore.dbo.vallsasemployees a
                              join tblpurchaseorders b on
                              a.employeenum = b.employeenum
                         --where a.employeenum = employeenum
where ponum = @intponum
                         )
WHERE PONum = @intPONum

ASP Page Code Sample (cut and pasted portions of the asp page):
<!--#include file="scripts/stylesheet.css"-->
<!--#include file="header.asp"-->
<!--#include file="scripts/OpenDb.asp"-->
<!--#include file="scripts/adovbs.inc"-->
 '**************************************************************
                    ' This page edits a single purchase order. The page allows all fields to
                    ' be edited so only Admins will ever see this.
                    '**************************************************************

                                           
                                           strAction = request("action")
                                        If (strAction = 1 Or strAction = 2) Then
                                            '   List Variables From the Form
                                             'strPO = request("PO")
                                             strPOnum = request.Form("ponum")
                                             strEmpNum = request("empnum")
                                             strdeptID = request("Department")
                                               strSupplier = request("supnum")
                                             'strFname = request("fname")
                                             'strLname = request("lname")  
                                              strWarehouse = request("warehousenum")
                                             strFreightCharge = request("freightcharge")  
                                               strMiscSurcharge = request("miscsurcharge")
                                      strDiscount = request("Discount")
                                    strArrivalDate = request("ArrivalDate")
'                                            strST = request("salestax")    
                                               'strRecurring = request("recurring")
                                              strFrequency = request("frequencytype")
                                              strComments = request("comments")
                                              strSalesTax = request("salestax")
                                Dim cmdStoredProc
 '                               Dim recordx
                               
                                Set cmdStoredProc = server.CreateObject("ADODB.Command")
                               
                                with cmdStoredProc
                                    .ActiveConnection=conn1
                                    .CommandType = adcmdstoredproc
                                    .CommandText = "UpdatePurchaseOrdersCPY"
                                    .parameters.append (.CreateParameter("@intPONum",adInteger,adParamInput,, cint(strPOnum)))
                                    .parameters.append (.CreateParameter("@intSupNum",adInteger,adParamInput,, cint(strSupplier)))
                                    .Parameters.append (.CreateParameter("@intEmployeeNum", adInteger, adParamInput, , cint(strEmpNum)))
                                    '.Parameters.append (.CreateParameter("@intDeptID", adVarchar, adParamInput,, cint(strdeptID)))
                                    .Parameters.append (.CreateParameter("@intWarehouseNum", adInteger,adParamInput,,cint(strWarehouse)))
                               

                             '       .Parameters.append (.CreateParameter("@intDeptID",adVarChar,adParamInput,50,trim(strdeptID)))
'                                    .Parameters.append (.CreateParameter("@vcLName",adVarChar,adParamInput,50,trim(strLname)))
                                    if strSalesTax = "" or isnull(strSalesTax) then
                                        .Parameters.append (.CreateParameter("@dcSalesTax", adDecimal,adParamInput,,0))
                                    else
                                        .Parameters.append (.CreateParameter("@dcSalesTax", adDecimal,adParamInput,,strSalesTax))
                                    end if
                                    .Parameters.item("@dcSalesTax").precision = 18
                                    .Parameters.item("@dcSalesTax").numericscale = 2

                                    if strFreightCharge = "" or isnull(strFreightCharge) then
                                        .Parameters.append (.CreateParameter("@dcFreightCharge", adDecimal,adParamInput,,0))
                                    else
                                        .Parameters.append (.CreateParameter("@dcFreightCharge", adDecimal,adParamInput,,strFreightCharge))
                                    end if
                                    .Parameters.item("@dcFreightCharge").precision = 18
                                    .Parameters.item("@dcFreightCharge").numericscale = 2

                                    if strMiscSurcharge = "" or isnull(strMiscSurcharge) then
                                        .Parameters.append (.CreateParameter("@dcMiscSurchargePercent", adDecimal, adParamInput, , 0))
                                        .Parameters.append (.CreateParameter("@dcMiscSurchargeCurrency", adDecimal, adParamInput, , 0))
                                    elseif request("miscsign") = "$" then
                                        .Parameters.append (.CreateParameter("@dcMiscSurchargePercent", adDecimal, adParamInput, , 0))
                                        .Parameters.append (.CreateParameter("@dcMiscSurchargeCurrency", adDecimal, adParamInput, , strMiscSurcharge))                                    
                                    else
                                        .Parameters.append (.CreateParameter("@dcMiscSurchargePercent", adDecimal, adParamInput, , strMiscSurcharge))
                                        .Parameters.append (.CreateParameter("@dcMiscSurchargeCurrency", adDecimal, adParamInput, , 0))
                                    end if
                                    .Parameters.item("@dcMiscSurchargePercent").precision = 18
                                    .Parameters.item("@dcMiscSurchargePercent").numericscale = 2
                                    .Parameters.item("@dcMiscSurchargeCurrency").precision = 18
                                    .Parameters.item("@dcMiscSurchargeCurrency").numericscale = 2



                                    if strDiscount = "" or isnull(strDiscount) then
                                        .Parameters.append (.CreateParameter("@dcDiscountPercent", adDecimal, adParamInput, , 0))
                                        .Parameters.append (.CreateParameter("@dcDiscountCurrency", adDecimal, adParamInput, , 0))
                                    elseif request("discsign") = "$" then
                                        .Parameters.append (.CreateParameter("@dcDiscountPercent", adDecimal, adParamInput, , 0))
                                        .Parameters.append (.CreateParameter("@dcDiscountCurrency", adDecimal, adParamInput, , strDiscount))                                    
                                    else
                                        .Parameters.append (.CreateParameter("@dcDiscountPercent", adDecimal, adParamInput, , strDiscount))
                                        .Parameters.append (.CreateParameter("@dcDiscountCurrency", adDecimal, adParamInput, , 0))
                                    end if
                                    .Parameters.item("@dcDiscountPercent").precision = 18
                                    .Parameters.item("@dcDiscountPercent").numericscale = 2
                                    .Parameters.item("@dcDiscountCurrency").precision = 18
                                    .Parameters.item("@dcDiscountCurrency").numericscale = 2
                                   
'                                    if strST = "" or isnull(strST) then
'                                        .Parameters.append (.CreateParameter("@dcSalesTax", adDecimal, adParamInput, , 0))
'                                    else
'                                        .Parameters.append (.CreateParameter("@dcSalesTax", adDecimal, adParamInput, , strST))
'                                    end if
'                                    .Parameters.item("@dcSalesTax").precision = 18
'                                    .Parameters.item("@dcSalesTax").numericscale = 2
                                   
                                    '.Parameters.append (.CreateParameter("@btRecurring", adBoolean, adParamInput, , cbool(strRecurring)))
                                    .Parameters.append (.CreateParameter("@vcFrequencyType", adVarchar, adParamInput, 50, trim(strFrequency)))
                                    .Parameters.append (.CreateParameter("@vcComments", adVarchar, adParamInput, len(trim(strcomments)), trim(strComments)))
                                    if request.Form("arrivaldate") = "" or isnull(request.Form("arrivaldate")) then
                                        .Parameters.append (.CreateParameter("@dtArrivalDate", adDBTimeStamp, adParamInput, , NULL))
                                    else                                    
                                        .Parameters.append (.CreateParameter("@dtArrivalDate", adDBTimeStamp, adParamInput, , request.Form("arrivaldate")))
                                    end if

                                    .Parameters.append (.CreateParameter("@vcShipToName", adVarChar,adParamInput,50, trim(request.Form("ShipToName"))))
                                    .Parameters.append (.CreateParameter("@vcShipToAddress", adVarChar,adParamInput,50, trim(request.Form("ShipToAddress"))))
                                    .Parameters.append (.CreateParameter("@vcShipToAddress2", adVarChar,adParamInput,50, trim(request.Form("ShipToAddress2"))))
                                    .Parameters.append (.CreateParameter("@vcShipToCity", adVarChar,adParamInput,50, trim(request.Form("ShipToCity"))))
                                    if trim(request.Form("ShipToCity")) = "" then
                                        .Parameters.append (.CreateParameter("@vcShipToState", adVarChar,adParamInput,50, ""))
                                    else
                                        .Parameters.append (.CreateParameter("@vcShipToState", adVarChar,adParamInput,50, trim(request.Form("State"))))
                                    end if
                                    .Parameters.append (.CreateParameter("@vcShipToZip", adVarChar,adParamInput,50, trim(request.Form("ShipToZip"))))

                                   
                                    .Execute
                                   
'                                    response.write "PONUM: " & cmdStoredProc.Parameters("@intPONum").Value & "#"
                                end with  
                                dim cmdstoredproc11
                                set cmdstoredproc11 = server.CreateObject("ADODB.Command")
                               with cmdStoredProc11
                                    .ActiveConnection=conn1
                                    .CommandType = adcmdstoredproc
                                    .CommandText = "UpdatePurchaseOrdersCPY3"
                                   ' .parameters.append (.CreateParameter("@intPONum",adInteger,adParamInput,, cint(strPOnum)))
                                    .Execute
                                   
'                                   response.write "PONUM: " & cmdStoredProc.Parameters("@intPONum").Value & "#"
                                end with  


Start Free Trial
[+][-]01.16.2008 at 10:11PM PST, ID: 20679097

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Active Server Pages (ASP)
Tags: SQL, ASP
Sign Up Now!
Solution Provided By: slamhound
Participating Experts: 1
Solution Grade: A
 
 
[+][-]01.17.2008 at 04:42AM PST, ID: 20680610

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.17.2008 at 04:43AM PST, ID: 20680617

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.17.2008 at 07:10AM PST, ID: 20681965

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906