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
.Connectio
n")
conn1.Open "Provider=SQLOLEDB; Data Source=SQL-VS01-PROD; Initial Catalog=PurchaseOrders; User ID=*; Password= *"
%>
SQL Stored Procedure:
USE PURCHASEORDERS
ALTER PROCEDURE [dbo].[UpdatePurchaseOrder
sCPY3]
@intPONum AS int
AS
update tblpurchaseorders
set deptID = (select cast(a.department as int)
from sascore.dbo.vallsasemploye
es 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.c
ss"-->
<!--#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("@intPON
um",adInte
ger,adPara
mInput,, cint(strPOnum)))
.parameters.append (.CreateParameter("@intSup
Num",adInt
eger,adPar
amInput,, cint(strSupplier)))
.Parameters.append (.CreateParameter("@intEmp
loyeeNum",
adInteger, adParamInput, , cint(strEmpNum)))
'.Parameters.append (.CreateParameter("@intDep
tID", adVarchar, adParamInput,, cint(strdeptID)))
.Parameters.append (.CreateParameter("@intWar
ehouseNum"
, adInteger,adParamInput,,ci
nt(strWare
house)))
' .Parameters.append (.CreateParameter("@intDep
tID",adVar
Char,adPar
amInput,50
,trim(strd
eptID)))
' .Parameters.append (.CreateParameter("@vcLNam
e",adVarCh
ar,adParam
Input,50,t
rim(strLna
me)))
if strSalesTax = "" or isnull(strSalesTax) then
.Parameters.append (.CreateParameter("@dcSale
sTax", adDecimal,adParamInput,,0)
)
else
.Parameters.append (.CreateParameter("@dcSale
sTax", adDecimal,adParamInput,,st
rSalesTax)
)
end if
.Parameters.item("@dcSales
Tax").prec
ision = 18
.Parameters.item("@dcSales
Tax").nume
ricscale = 2
if strFreightCharge = "" or isnull(strFreightCharge) then
.Parameters.append (.CreateParameter("@dcFrei
ghtCharge"
, adDecimal,adParamInput,,0)
)
else
.Parameters.append (.CreateParameter("@dcFrei
ghtCharge"
, adDecimal,adParamInput,,st
rFreightCh
arge))
end if
.Parameters.item("@dcFreig
htCharge")
.precision
= 18
.Parameters.item("@dcFreig
htCharge")
.numericsc
ale = 2
if strMiscSurcharge = "" or isnull(strMiscSurcharge) then
.Parameters.append (.CreateParameter("@dcMisc
SurchargeP
ercent", adDecimal, adParamInput, , 0))
.Parameters.append (.CreateParameter("@dcMisc
SurchargeC
urrency", adDecimal, adParamInput, , 0))
elseif request("miscsign") = "$" then
.Parameters.append (.CreateParameter("@dcMisc
SurchargeP
ercent", adDecimal, adParamInput, , 0))
.Parameters.append (.CreateParameter("@dcMisc
SurchargeC
urrency", adDecimal, adParamInput, , strMiscSurcharge))
else
.Parameters.append (.CreateParameter("@dcMisc
SurchargeP
ercent", adDecimal, adParamInput, , strMiscSurcharge))
.Parameters.append (.CreateParameter("@dcMisc
SurchargeC
urrency", adDecimal, adParamInput, , 0))
end if
.Parameters.item("@dcMiscS
urchargePe
rcent").pr
ecision = 18
.Parameters.item("@dcMiscS
urchargePe
rcent").nu
mericscale
= 2
.Parameters.item("@dcMiscS
urchargeCu
rrency").p
recision = 18
.Parameters.item("@dcMiscS
urchargeCu
rrency").n
umericscal
e = 2
if strDiscount = "" or isnull(strDiscount) then
.Parameters.append (.CreateParameter("@dcDisc
ountPercen
t", adDecimal, adParamInput, , 0))
.Parameters.append (.CreateParameter("@dcDisc
ountCurren
cy", adDecimal, adParamInput, , 0))
elseif request("discsign") = "$" then
.Parameters.append (.CreateParameter("@dcDisc
ountPercen
t", adDecimal, adParamInput, , 0))
.Parameters.append (.CreateParameter("@dcDisc
ountCurren
cy", adDecimal, adParamInput, , strDiscount))
else
.Parameters.append (.CreateParameter("@dcDisc
ountPercen
t", adDecimal, adParamInput, , strDiscount))
.Parameters.append (.CreateParameter("@dcDisc
ountCurren
cy", adDecimal, adParamInput, , 0))
end if
.Parameters.item("@dcDisco
untPercent
").precisi
on = 18
.Parameters.item("@dcDisco
untPercent
").numeric
scale = 2
.Parameters.item("@dcDisco
untCurrenc
y").precis
ion = 18
.Parameters.item("@dcDisco
untCurrenc
y").numeri
cscale = 2
' if strST = "" or isnull(strST) then
' .Parameters.append (.CreateParameter("@dcSale
sTax", adDecimal, adParamInput, , 0))
' else
' .Parameters.append (.CreateParameter("@dcSale
sTax", adDecimal, adParamInput, , strST))
' end if
' .Parameters.item("@dcSales
Tax").prec
ision = 18
' .Parameters.item("@dcSales
Tax").nume
ricscale = 2
'.Parameters.append (.CreateParameter("@btRecu
rring", adBoolean, adParamInput, , cbool(strRecurring)))
.Parameters.append (.CreateParameter("@vcFreq
uencyType"
, adVarchar, adParamInput, 50, trim(strFrequency)))
.Parameters.append (.CreateParameter("@vcComm
ents", adVarchar, adParamInput, len(trim(strcomments)), trim(strComments)))
if request.Form("arrivaldate"
) = "" or isnull(request.Form("arriv
aldate")) then
.Parameters.append (.CreateParameter("@dtArri
valDate", adDBTimeStamp, adParamInput, , NULL))
else
.Parameters.append (.CreateParameter("@dtArri
valDate", adDBTimeStamp, adParamInput, , request.Form("arrivaldate"
)))
end if
.Parameters.append (.CreateParameter("@vcShip
ToName", adVarChar,adParamInput,50,
trim(request.Form("ShipToN
ame"))))
.Parameters.append (.CreateParameter("@vcShip
ToAddress"
, adVarChar,adParamInput,50,
trim(request.Form("ShipToA
ddress")))
)
.Parameters.append (.CreateParameter("@vcShip
ToAddress2
", adVarChar,adParamInput,50,
trim(request.Form("ShipToA
ddress2"))
))
.Parameters.append (.CreateParameter("@vcShip
ToCity", adVarChar,adParamInput,50,
trim(request.Form("ShipToC
ity"))))
if trim(request.Form("ShipToC
ity")) = "" then
.Parameters.append (.CreateParameter("@vcShip
ToState", adVarChar,adParamInput,50,
""))
else
.Parameters.append (.CreateParameter("@vcShip
ToState", adVarChar,adParamInput,50,
trim(request.Form("State")
)))
end if
.Parameters.append (.CreateParameter("@vcShip
ToZip", adVarChar,adParamInput,50,
trim(request.Form("ShipToZ
ip"))))
.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("@intPON
um",adInte
ger,adPara
mInput,, cint(strPOnum)))
.Execute
' response.write "PONUM: " & cmdStoredProc.Parameters("
@intPONum"
).Value & "#"
end with
Start Free Trial