473,382 Members | 1,376 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Accessing Stored Procedure from IIS

I have a stored procedure that is supposed to
1. Increment a counter in Table A via a transaction
2. Use this value as the primary key to add in an address to customers
Table B
(Referenced as a "DECLARE @CustomerID INT" just after the AS
clause)
3. Return the primary key.

This works perfectly when being called from Query Analyzer supplying values
in an EXEC line, however, accessing it from .ASP (IIS 5.0 on Win2K), the
execution falls right through without adding the customer or incrementing
the counter or giving an error. All conditional routines are executed, but
no work is being done.

Is there anything I can do to raise some sort of error to let me know what
is or isn't happening?

adovbs.inc is linked and the "conditional code" I refer to swaps the stored
procedure name (for add/edit) to add in one more parameter needed for
editing records. The parameters are referenced in exactly the same order as
they are in the procedures, with the return value being mentioned first.

The append parameters lines have been rewritten in short form, long form,
and in a "with" block as shown.

for example:

(Blocked within conditional code)

adocmd.CommandType = adCmdStoredProc
adocmd.CommandText = "spr_AddCustomer"
adocmd.ActiveConnection = conn.ConnectionObject

set param = adocmd.createparameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
adocmd.parameters.append param

(Conditional code end)

With adocmd

set param = .createparameter("@Company", adVarChar, adParamInput, 40,
company)
.parameters.append param
set param = .createparameter("@FirstName", adVarChar, adParamInput, 15,
firstname)
.parameters.append param
set param = .createparameter("@MiddleInitial", adVarChar, adParamInput,
1, middleinitial)
.parameters.append param
set param = .createparameter("@LastName", adVarChar, adParamInput, 20,
lastname)
.parameters.append param

.... (continuing to add parameters in the same order as SP)

.execute lngRecs,,adexecutenorecords
CustomerId = .Parameters("@RETURN_VALUE").Value

End With
Jul 22 '05 #1
4 1744
Make sure you disable "on error resume next" in your ASP page.
Make sure the stored procedure has SET NOCOUNT ON at the beginning.
Have a look at http://www.aspfaq.com/2201

--
http://www.aspfaq.com/
(Reverse address to reply.)


"stjulian" <an*******@discussions.microsoft.com> wrote in message
news:#l**************@TK2MSFTNGP09.phx.gbl...
I have a stored procedure that is supposed to
1. Increment a counter in Table A via a transaction
2. Use this value as the primary key to add in an address to customers
Table B
(Referenced as a "DECLARE @CustomerID INT" just after the AS
clause)
3. Return the primary key.

This works perfectly when being called from Query Analyzer supplying values in an EXEC line, however, accessing it from .ASP (IIS 5.0 on Win2K), the
execution falls right through without adding the customer or incrementing
the counter or giving an error. All conditional routines are executed, but
no work is being done.

Is there anything I can do to raise some sort of error to let me know what
is or isn't happening?

adovbs.inc is linked and the "conditional code" I refer to swaps the stored procedure name (for add/edit) to add in one more parameter needed for
editing records. The parameters are referenced in exactly the same order as they are in the procedures, with the return value being mentioned first.

The append parameters lines have been rewritten in short form, long form,
and in a "with" block as shown.

for example:

(Blocked within conditional code)

adocmd.CommandType = adCmdStoredProc
adocmd.CommandText = "spr_AddCustomer"
adocmd.ActiveConnection = conn.ConnectionObject

set param = adocmd.createparameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
adocmd.parameters.append param

(Conditional code end)

With adocmd

set param = .createparameter("@Company", adVarChar, adParamInput, 40,
company)
.parameters.append param
set param = .createparameter("@FirstName", adVarChar, adParamInput, 15,
firstname)
.parameters.append param
set param = .createparameter("@MiddleInitial", adVarChar, adParamInput,
1, middleinitial)
.parameters.append param
set param = .createparameter("@LastName", adVarChar, adParamInput, 20,
lastname)
.parameters.append param

.... (continuing to add parameters in the same order as SP)

.execute lngRecs,,adexecutenorecords
CustomerId = .Parameters("@RETURN_VALUE").Value

End With

Jul 22 '05 #2
Hi

You don't provide DDL for the procedure.
http://www.aspfaq.com/etiquette.asp?id=5006

You may want to check what is happening using profiler, and make sure that
NOCOUNT is ON.

John
"stjulian" wrote:
I have a stored procedure that is supposed to
1. Increment a counter in Table A via a transaction
2. Use this value as the primary key to add in an address to customers
Table B
(Referenced as a "DECLARE @CustomerID INT" just after the AS
clause)
3. Return the primary key.

This works perfectly when being called from Query Analyzer supplying values
in an EXEC line, however, accessing it from .ASP (IIS 5.0 on Win2K), the
execution falls right through without adding the customer or incrementing
the counter or giving an error. All conditional routines are executed, but
no work is being done.

Is there anything I can do to raise some sort of error to let me know what
is or isn't happening?

adovbs.inc is linked and the "conditional code" I refer to swaps the stored
procedure name (for add/edit) to add in one more parameter needed for
editing records. The parameters are referenced in exactly the same order as
they are in the procedures, with the return value being mentioned first.

The append parameters lines have been rewritten in short form, long form,
and in a "with" block as shown.

for example:

(Blocked within conditional code)

adocmd.CommandType = adCmdStoredProc
adocmd.CommandText = "spr_AddCustomer"
adocmd.ActiveConnection = conn.ConnectionObject

set param = adocmd.createparameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
adocmd.parameters.append param

(Conditional code end)

With adocmd

set param = .createparameter("@Company", adVarChar, adParamInput, 40,
company)
.parameters.append param
set param = .createparameter("@FirstName", adVarChar, adParamInput, 15,
firstname)
.parameters.append param
set param = .createparameter("@MiddleInitial", adVarChar, adParamInput,
1, middleinitial)
.parameters.append param
set param = .createparameter("@LastName", adVarChar, adParamInput, 20,
lastname)
.parameters.append param

.... (continuing to add parameters in the same order as SP)

.execute lngRecs,,adexecutenorecords
CustomerId = .Parameters("@RETURN_VALUE").Value

End With

Jul 22 '05 #3
Thank you both for your attention....
DDL follows
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

/****** Object: Stored Procedure dbo.spr_WriteCustomers Created: 2/24/05
JS ******/
CREATE PROCEDURE spr_WriteCustomers

@Company varchar(40) = NULL,
@FirstName varchar(15) = NULL,
@MiddleInitial varchar(1) = NULL,
@LastName varchar(20) = NULL,
@Title varchar(30) = NULL,
@BillingAttnLine varchar(40) = NULL,
@BillingAddress1 varchar(40) = NULL,
@BillingAddress2 varchar(40) = NULL,
@BillingCity varchar(20) = NULL,
@BillingState varchar(3) = NULL,
@BillingZip varchar(10) = NULL,
@FK_CountryCode varchar(3) = NULL,
@BillingCountry varchar(25) = NULL,
@BillingPhone varchar(25) = NULL,
@BillingFax varchar(15) = NULL,

@ShippingFirstName varchar(15) = NULL,
@ShippingLastName varchar(20) = NULL,
@ShippingCompany varchar(40) = NULL,
@ShippingTitle varchar(40) = NULL,
@ShippingAttnLine varchar(40) = NULL,
@ShippingAddress1 varchar(40) = NULL,
@ShippingAddress2 varchar(40) = NULL,
@ShippingCity varchar(20) = NULL,
@ShippingState varchar(3) = NULL,
@ShippingZip varchar(10) = NULL,
@FK_SCountryCode varchar(3) = NULL,
@ShippingCountry varchar(25) = NULL,
@ShippingPhone varchar(25) = NULL,
@ShippingFax varchar(15) = NULL,

@FK_CustomerTierID int = 0,
@UserName varchar(45) = NULL,
@Password varchar(20) = NULL,
@EMail varchar(45) = NULL,

@TaxExempt bit = 0,
@NoEmail bit= 0,
@GREETING1 varchar(35) = NULL,
@GREETING2 varchar(35) = NULL,
@BelongsTo int = 0

AS
BEGIN
SET NOCOUNT ON
DECLARE @custid INT
DECLARE @CREATEDATE DATETIME

--- Begin process
--Get New CustomerID
BEGIN TRAN
SELECT @custid = nextid
FROM tblAutoNumber
WHERE TableName = 'tblCustomers'

UPDATE tblAutoNumber
SET nextid = @custid + 1
WHERE TableName = 'tblCustomers'
COMMIT TRAN

SELECT @CREATEDATE = getdate()

BEGIN
INSERT INTO tblCustomers
(PK_ID,
Company,
FirstName,
MiddleInitial,
LastName,
Title,
BillingAttnLine,
BillingAddress1,
BillingAddress2,
BillingCity,
BillingState,
BillingZip,
FK_CountryCode,
BillingCountry,
ShippingFirstName,
ShippingLastName,
ShippingCompany,
ShippingTitle,
ShippingAttnLine,
ShippingAddress1,
ShippingAddress2,
ShippingCity,
ShippingState,
ShippingZip,
FK_SCountryCode,
ShippingCountry,
FK_CustomerTierID,
UserName,
Password,
Email,
BillingPhone,
ShippingPhone,
BillingFax,
ShippingFax,
LeaseStatus,
LeaseCreditLimit,
FK_CurrencyId,
DisableLogin,
LastModified,
Created,
TaxExempt,
NoEmail,
GREETING1,
GREETING2,
TaxExemptVerified,
AutoCancel,
LastLogin,
BelongsTo)

VALUES(
@custid,
@Company,
@FirstName,
@MiddleInitial,
@LastName,
@Title,
@BillingAttnLine,
@BillingAddress1,
@BillingAddress2,
@BillingCity,
@BillingState,
@BillingZip,
@FK_CountryCode,
@BillingCountry,
@ShippingFirstName,
@ShippingLastName,
@ShippingCompany,
@ShippingTitle,
@ShippingAttnLine,
@ShippingAddress1,
@ShippingAddress2,
@ShippingCity,
@ShippingState,
@ShippingZip,
@FK_SCountryCode,
@ShippingCountry,
@FK_CustomerTierID,
@UserName,
@Password,
@Email,
@BillingPhone,
@ShippingPhone,
@BillingFax,
@ShippingFax,
'',
0,
0,
0,
@CREATEDATE,
@CREATEDATE,
@TaxExempt,
@NoEmail,
@GREETING1,
@GREETING2,
0,
0,
@CREATEDATE,
@BelongsTo)

END
RETURN @custid

END

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

"John Bell" <Jo******@discussions.microsoft.com> wrote in message
news:A7**********************************@microsof t.com...
Hi

You don't provide DDL for the procedure.
http://www.aspfaq.com/etiquette.asp?id=5006

You may want to check what is happening using profiler, and make sure that
NOCOUNT is ON.

John
"stjulian" wrote:
I have a stored procedure that is supposed to
1. Increment a counter in Table A via a transaction
2. Use this value as the primary key to add in an address to
customers
Table B
(Referenced as a "DECLARE @CustomerID INT" just after the AS
clause)
3. Return the primary key.

This works perfectly when being called from Query Analyzer supplying
values
in an EXEC line, however, accessing it from .ASP (IIS 5.0 on Win2K), the
execution falls right through without adding the customer or incrementing
the counter or giving an error. All conditional routines are executed,
but
no work is being done.

Is there anything I can do to raise some sort of error to let me know
what
is or isn't happening?

adovbs.inc is linked and the "conditional code" I refer to swaps the
stored
procedure name (for add/edit) to add in one more parameter needed for
editing records. The parameters are referenced in exactly the same order
as
they are in the procedures, with the return value being mentioned first.

The append parameters lines have been rewritten in short form, long form,
and in a "with" block as shown.

for example:

(Blocked within conditional code)

adocmd.CommandType = adCmdStoredProc
adocmd.CommandText = "spr_AddCustomer"
adocmd.ActiveConnection = conn.ConnectionObject

set param = adocmd.createparameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
adocmd.parameters.append param

(Conditional code end)

With adocmd

set param = .createparameter("@Company", adVarChar, adParamInput, 40,
company)
.parameters.append param
set param = .createparameter("@FirstName", adVarChar, adParamInput,
15,
firstname)
.parameters.append param
set param = .createparameter("@MiddleInitial", adVarChar,
adParamInput,
1, middleinitial)
.parameters.append param
set param = .createparameter("@LastName", adVarChar, adParamInput, 20,
lastname)
.parameters.append param

.... (continuing to add parameters in the same order as SP)

.execute lngRecs,,adexecutenorecords
CustomerId = .Parameters("@RETURN_VALUE").Value

End With

Jul 22 '05 #4
Wait, I think I got it .... The On Error was in an include file.

Thank you all for your help.

Julian
"John Bell" <Jo******@discussions.microsoft.com> wrote in message
news:A7**********************************@microsof t.com...
Hi

You don't provide DDL for the procedure.
http://www.aspfaq.com/etiquette.asp?id=5006

You may want to check what is happening using profiler, and make sure that
NOCOUNT is ON.

John
"stjulian" wrote:
I have a stored procedure that is supposed to
1. Increment a counter in Table A via a transaction
2. Use this value as the primary key to add in an address to
customers
Table B
(Referenced as a "DECLARE @CustomerID INT" just after the AS
clause)
3. Return the primary key.

This works perfectly when being called from Query Analyzer supplying
values
in an EXEC line, however, accessing it from .ASP (IIS 5.0 on Win2K), the
execution falls right through without adding the customer or incrementing
the counter or giving an error. All conditional routines are executed,
but
no work is being done.

Is there anything I can do to raise some sort of error to let me know
what
is or isn't happening?

adovbs.inc is linked and the "conditional code" I refer to swaps the
stored
procedure name (for add/edit) to add in one more parameter needed for
editing records. The parameters are referenced in exactly the same order
as
they are in the procedures, with the return value being mentioned first.

The append parameters lines have been rewritten in short form, long form,
and in a "with" block as shown.

for example:

(Blocked within conditional code)

adocmd.CommandType = adCmdStoredProc
adocmd.CommandText = "spr_AddCustomer"
adocmd.ActiveConnection = conn.ConnectionObject

set param = adocmd.createparameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
adocmd.parameters.append param

(Conditional code end)

With adocmd

set param = .createparameter("@Company", adVarChar, adParamInput, 40,
company)
.parameters.append param
set param = .createparameter("@FirstName", adVarChar, adParamInput,
15,
firstname)
.parameters.append param
set param = .createparameter("@MiddleInitial", adVarChar,
adParamInput,
1, middleinitial)
.parameters.append param
set param = .createparameter("@LastName", adVarChar, adParamInput, 20,
lastname)
.parameters.append param

.... (continuing to add parameters in the same order as SP)

.execute lngRecs,,adexecutenorecords
CustomerId = .Parameters("@RETURN_VALUE").Value

End With

Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: crisp99 | last post by:
Hi, I have a SQL Stored Procedure : CREATE PROCEDURE spFilterOne @city varchar(25) AS SELECT * FROM tblCities WHERE tblCities.strCity = @city ORDER BY tblCities.strName
1
by: - | last post by:
this is one way of creating a stored procedure in mysql: CREATE PROCEDURE some_procedure (IN value1, OUT value2) BEGIN SELECT ... INTO value2 FROM .... END// and if called from another...
7
by: Mike Hubbard | last post by:
I have read many many messages about temporary tables and stored procedures. Still, I am struggling with a simple concept. I have a java program which creates a temporary table. I now want to...
4
by: Mullin Yu | last post by:
i have a stored procedure at sql server 2k. which will update records and select result from temp table. if i use SqlConnection class, and i do both. but, if i use OleDbConnection class, i can...
2
by: KimD | last post by:
I'm filling a dataset with the return of a stored procedure. The dataset contains a number of tables which I am naming within the stored procedure, however when I try to access the tables using the...
8
by: Christopher Weaver | last post by:
I'm having trouble accessing the value of an output parameter of a stored procedure. The SP looks like this: SET TERM ^ ; CREATE PROCEDURE SP_NEW_TASK RETURNS ( "uidTask" INTEGER) AS begin
1
by: Evan Kontos | last post by:
I am having an issue w/regard to stored procedures. If I do the following: Dim OccCnctn As New OleDb.OleDbConnection Dim OccCmd As New OleDb.OleDbCommand Dim OccRdr As OleDb.OleDbDataReader...
12
by: Steve Blinkhorn | last post by:
Does anyone know of a way of accessing and modifying variables declared static within a function from outside that function? Please no homilies on why it's bad practice: the context is very...
0
by: thedoctor | last post by:
I have a stored procedure which has a table as one of its "out" parameters. I'm not able to call this procedure from c# .net. please let me know how i can access it. The procedure has been called...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.