Greets,
I'm new to stored procedures. My ASP page collects query info eg field names to query, and query strings.
My stored procedure reads...
ALTER Procedure inetPasysList
(
@pAssetNo varchar(40) =null,
@pDescription varchar (40) =null,
@pBrand varchar (40) =null,
@pModel varchar (40) =null,
@pSerialNo varchar (40) =null,
@pAcquisitionDate datetime =null,
@pValueAtAcqusition int =null,
@pPurchaseOrderNo varchar (50) =null,
@pSupplier varchar (35) =null,
@pSupplierInvoiceNo varchar (10) =null,
@pLocation varchar (6) =null,
@pResponsibleOfficer varchar (40) =null,
@pCostCode varchar (6) =null,
@pCategory varchar (40) =null,
@pTransferTo varchar (10) =null,
@pTransferFrom varchar (10) =null,
@pDisposalDate DateTime =null,
@pMethodOfDisposal varchar (10) =null,
@pCorrectionalCentre varchar (50) =null,
@pActive bit =null
)
As
SELECT *
FROM pasys
WHERE AssetNo like isnull(@pAssetNo, AssetNo)
and Description like isnull(@pDescription, Description)
and Brand like isnull(@pBrand, Brand)
and Model like isnull(@pModel, Model)
and SerialNo like isnull(@pSerialNo, SerialNo)
and AcquisitionDate like isnull(@pAcquisitionDate, AcquisitionDate)
and ValueAtAcqusition like isnull(@pValueAtAcqusition, ValueAtAcqusition)
and PurchaseOrderNo like isnull(@pPurchaseOrderNo, PurchaseOrderNo)
and Supplier like isnull(@pSupplier, Supplier)
and SupplierInvoiceNo like isnull(@pSupplierInvoiceNo, SupplierInvoiceNo)
and Location like isnull(@pLocation, Location)
and ResponsibleOfficer like isnull(@pResponsibleOfficer, ResponsibleOfficer)
and CostCode like isnull(@pCostCode, CostCode)
and Category like isnull(@pCategory, Category)
and TransferTo like isnull(@pTransferTo, TransferTo)
and TransferFrom like isnull(@pTransferFrom, TransferFrom)
and DisposalDate like isnull(@pDisposalDate, DisposalDate)
and MethodOfDisposal like isnull(@pMethodOfDisposal, MethodOfDisposal)
and CorrectionalCentre like isnull(@pCorrectionalCentre, CorrectionalCentre)
and Active like isnull(@pActive, Active)
mmm... heres my asp code
set tDConnection = server.createObject("ADODB.Connection"
tDConnection.Open "PROVIDER=SQLOLEDB;DATA SOURCE=servername;UID=userid;PWD=password;DATABASE=pasys"
Set cmd = Server.CreateObject("ADODB.Command"
Set cmd.ActiveConnection = tDConnection
cmd.CommandText = "inetPasysList" ' name of sp
cmd.CommandType = adCmdStoredProc
' Ask the server about the parameters for the stored proc
cmd.Parameters.Refresh
tP1 = "@p" & tField1_Name
if tField1_Value <> "" then
cmd.Parameters(tP1) = tField1_Value
end if
tP2 = "@p" & tField2_Name
if tField2_Value <> "" then
cmd.Parameters(tP2) = tField2_Value
end if
Set xrs = cmd.Execute
should this work?
p
I'm new to stored procedures. My ASP page collects query info eg field names to query, and query strings.
My stored procedure reads...
ALTER Procedure inetPasysList
(
@pAssetNo varchar(40) =null,
@pDescription varchar (40) =null,
@pBrand varchar (40) =null,
@pModel varchar (40) =null,
@pSerialNo varchar (40) =null,
@pAcquisitionDate datetime =null,
@pValueAtAcqusition int =null,
@pPurchaseOrderNo varchar (50) =null,
@pSupplier varchar (35) =null,
@pSupplierInvoiceNo varchar (10) =null,
@pLocation varchar (6) =null,
@pResponsibleOfficer varchar (40) =null,
@pCostCode varchar (6) =null,
@pCategory varchar (40) =null,
@pTransferTo varchar (10) =null,
@pTransferFrom varchar (10) =null,
@pDisposalDate DateTime =null,
@pMethodOfDisposal varchar (10) =null,
@pCorrectionalCentre varchar (50) =null,
@pActive bit =null
)
As
SELECT *
FROM pasys
WHERE AssetNo like isnull(@pAssetNo, AssetNo)
and Description like isnull(@pDescription, Description)
and Brand like isnull(@pBrand, Brand)
and Model like isnull(@pModel, Model)
and SerialNo like isnull(@pSerialNo, SerialNo)
and AcquisitionDate like isnull(@pAcquisitionDate, AcquisitionDate)
and ValueAtAcqusition like isnull(@pValueAtAcqusition, ValueAtAcqusition)
and PurchaseOrderNo like isnull(@pPurchaseOrderNo, PurchaseOrderNo)
and Supplier like isnull(@pSupplier, Supplier)
and SupplierInvoiceNo like isnull(@pSupplierInvoiceNo, SupplierInvoiceNo)
and Location like isnull(@pLocation, Location)
and ResponsibleOfficer like isnull(@pResponsibleOfficer, ResponsibleOfficer)
and CostCode like isnull(@pCostCode, CostCode)
and Category like isnull(@pCategory, Category)
and TransferTo like isnull(@pTransferTo, TransferTo)
and TransferFrom like isnull(@pTransferFrom, TransferFrom)
and DisposalDate like isnull(@pDisposalDate, DisposalDate)
and MethodOfDisposal like isnull(@pMethodOfDisposal, MethodOfDisposal)
and CorrectionalCentre like isnull(@pCorrectionalCentre, CorrectionalCentre)
and Active like isnull(@pActive, Active)
mmm... heres my asp code
set tDConnection = server.createObject("ADODB.Connection"

tDConnection.Open "PROVIDER=SQLOLEDB;DATA SOURCE=servername;UID=userid;PWD=password;DATABASE=pasys"
Set cmd = Server.CreateObject("ADODB.Command"

Set cmd.ActiveConnection = tDConnection
cmd.CommandText = "inetPasysList" ' name of sp
cmd.CommandType = adCmdStoredProc
' Ask the server about the parameters for the stored proc
cmd.Parameters.Refresh
tP1 = "@p" & tField1_Name
if tField1_Value <> "" then
cmd.Parameters(tP1) = tField1_Value
end if
tP2 = "@p" & tField2_Name
if tField2_Value <> "" then
cmd.Parameters(tP2) = tField2_Value
end if
Set xrs = cmd.Execute
should this work?
p