473,769 Members | 3,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.ASP, MTS transactions, and stored procedure I/O variables

I've got a webpage that calls some stored procedures with input variables.
The procedures return recordsets and also some output variables. We're
trying to get the values of the output variables. I've done this using the
method I found in MSDN, as shown in the code below. The problem is that we
believe doing it this way involves the use of the Microsoft Transaction
Server (IIS transaction server). Is this true? (The SQL Server and IIS
Server are on different machines and, I believe, a firewall separates them.)

I can't see why this method would use MTS. The problem is that in the past,
we have had problems with MTS stopping for no reason, which causes the
websites to not work. So my boss doesn't want to use any ASP code that
relies on MTS. Not using the stored procedure output variables makes things
way more complicated. So does this code really invoke MTS? And if it does,
is there a way to obtain SP output variables without using MTS?

I am running SQL Server 7.0 with the latest service pack and IIS version 4.
We do have an IIS version 5 server we can use if that matters.

Thanks,

Shaun
Set oCmd = Server.CreateOb ject("ADODB.Com mand")
oCmd.ActiveConn ection = Application("on acctEpi_Connect ionString")
oCmd.CommandTex t = "CPREP_GetRegio n"
oCmd.CommandTyp e = adCmdStoredProc

oCmd.Parameters .Append
oCmd.CreatePara meter("@locatio n",adVarChar,ad ParamInput,8,lo cationchoice)
oCmd.Parameters .Append
oCmd.CreatePara meter("@method" ,adVarChar,adPa ramInput,8,frtc hoicecode)
oCmd.Parameters .Append
oCmd.CreatePara meter("@zip",ad VarChar,adParam Input,40,zipcod e)

oCmd.Parameters .Append
oCmd.CreatePara meter("@region" ,adVarChar,adPa ramOutput,8,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_cod e",adInteger,ad ParamOutput,,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_msg ",adVarChar,adP aramOutput,75,0 )

oCmd.Execute, ,adExecuteNoRec ords

region = oCmd.Parameters ("@region")
rtn_code = oCmd.Parameters ("@rtn_code" )
rtn_msg = oCmd.Parameters ("@rtn_msg")
Jul 19 '05 #1
6 2083
Anytime you use

Server.CreateOb ject

MTS (COM+) is involved. If you do not want MTS to be involved, use
CreateObject (without the "Server.").

There is nothing intrinsic in the use of a Command object that causes MTS to
be involved.

There are two ways to get output variables from your stored procedures:

Command object (recommended)
See your code

Dynamic SQL (not recommended)
sSQL = "declare @P1 int, @P2 int; Set @P1 = 0;" & _
"Set @P2=" & userinput & ";" & _
"exec someproc @P1 output, @P2;" & _
"SELECT @P1 As OutParm"
Set cn=createobject ("adodb.connect ion")
cn.open Application("on acctEpi_Connect ionString")
Set rs=cn.execute(s SQL,,1)

'if the procedure returned records, then process them here.
'then
Set rs = rs.NextRecordse t
outputparm = rs(0)
HTH,
Bob Barrows
Shaun Stuart wrote:
I've got a webpage that calls some stored procedures with input
variables. The procedures return recordsets and also some output
variables. We're trying to get the values of the output variables.
I've done this using the method I found in MSDN, as shown in the code
below. The problem is that we believe doing it this way involves the
use of the Microsoft Transaction Server (IIS transaction server). Is
this true? (The SQL Server and IIS Server are on different machines
and, I believe, a firewall separates them.)

I can't see why this method would use MTS. The problem is that in the
past, we have had problems with MTS stopping for no reason, which
causes the websites to not work. So my boss doesn't want to use any
ASP code that relies on MTS. Not using the stored procedure output
variables makes things way more complicated. So does this code really
invoke MTS? And if it does, is there a way to obtain SP output
variables without using MTS?

I am running SQL Server 7.0 with the latest service pack and IIS
version 4. We do have an IIS version 5 server we can use if that
matters.

Thanks,

Shaun
Set oCmd = Server.CreateOb ject("ADODB.Com mand")
oCmd.ActiveConn ection = Application("on acctEpi_Connect ionString")
oCmd.CommandTex t = "CPREP_GetRegio n"
oCmd.CommandTyp e = adCmdStoredProc

oCmd.Parameters .Append
oCmd.CreatePara meter("@locatio n",adVarChar,ad ParamInput,8,lo cationchoice)
oCmd.Parameters .Append
oCmd.CreatePara meter("@method" ,adVarChar,adPa ramInput,8,frtc hoicecode)
oCmd.Parameters .Append
oCmd.CreatePara meter("@zip",ad VarChar,adParam Input,40,zipcod e)

oCmd.Parameters .Append
oCmd.CreatePara meter("@region" ,adVarChar,adPa ramOutput,8,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_cod e",adInteger,ad ParamOutput,,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_msg ",adVarChar,adP aramOutput,75,0 )

oCmd.Execute, ,adExecuteNoRec ords

region = oCmd.Parameters ("@region")
rtn_code = oCmd.Parameters ("@rtn_code" )
rtn_msg = oCmd.Parameters ("@rtn_msg")


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2

The following is quoted from the article Windows 2000 Web Server Best
Practices for High Availability at
http://www.microsoft.com/technet/pro.../websrvbp.mspx

"Always use Server.CreateOb ject.
Using Server.CreateOb ject allows ASP to track the object instance. The
server portion causes the object to be created in a transaction server
package so resources are pooled. Using the CreateObject and GetObject
functions in server-side scripts rather than Server.CreateOb ject does not
allow for access to ASP built-in objects or participate in transactions.
Using CreateObject and GetObject will attach each new object to a separate
thread which will consume available system resources much faster than using
the connection pooling features available by using Server.CreateOb ject."

The use of Server.CreateOb ject will in no way involve your code in a
distributed transaction. It sounds like your boss may have taken a stance
based on a lack of experience with and understanding of the platform.

Of course, I can't totally discount the old YMMV axiom - he could have
stumbled on a bug that manifests in your environment.

--
Michael D. Long

"Shaun Stuart" <sstuartA-TproNsOoSfPtAtM rainingD-O-Tcom> wrote in message
news:ev******** *****@tk2msftng p13.phx.gbl...
I've got a webpage that calls some stored procedures with input variables.
The procedures return recordsets and also some output variables. We're
trying to get the values of the output variables. I've done this using the
method I found in MSDN, as shown in the code below. The problem is that we
believe doing it this way involves the use of the Microsoft Transaction
Server (IIS transaction server). Is this true? (The SQL Server and IIS
Server are on different machines and, I believe, a firewall separates
them.)

I can't see why this method would use MTS. The problem is that in the
past,
we have had problems with MTS stopping for no reason, which causes the
websites to not work. So my boss doesn't want to use any ASP code that
relies on MTS. Not using the stored procedure output variables makes
things
way more complicated. So does this code really invoke MTS? And if it does,
is there a way to obtain SP output variables without using MTS?

I am running SQL Server 7.0 with the latest service pack and IIS version
4.
We do have an IIS version 5 server we can use if that matters.

Thanks,

Shaun
Set oCmd = Server.CreateOb ject("ADODB.Com mand")
oCmd.ActiveConn ection = Application("on acctEpi_Connect ionString")
oCmd.CommandTex t = "CPREP_GetRegio n"
oCmd.CommandTyp e = adCmdStoredProc

oCmd.Parameters .Append
oCmd.CreatePara meter("@locatio n",adVarChar,ad ParamInput,8,lo cationchoice)
oCmd.Parameters .Append
oCmd.CreatePara meter("@method" ,adVarChar,adPa ramInput,8,frtc hoicecode)
oCmd.Parameters .Append
oCmd.CreatePara meter("@zip",ad VarChar,adParam Input,40,zipcod e)

oCmd.Parameters .Append
oCmd.CreatePara meter("@region" ,adVarChar,adPa ramOutput,8,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_cod e",adInteger,ad ParamOutput,,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_msg ",adVarChar,adP aramOutput,75,0 )

oCmd.Execute, ,adExecuteNoRec ords

region = oCmd.Parameters ("@region")
rtn_code = oCmd.Parameters ("@rtn_code" )
rtn_msg = oCmd.Parameters ("@rtn_msg")

Jul 19 '05 #3
Michael D. Long wrote:
The following is quoted from the article Windows 2000 Web Server Best
Practices for High Availability at
http://www.microsoft.com/technet/pro.../websrvbp.mspx

"Always use Server.CreateOb ject.
Using Server.CreateOb ject allows ASP to track the object instance. The


According to Egbert, this advice is a little outdated:
http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl
http://www.google.com/groups?hl=en&l...r%3D%26hl%3Den

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4
Thanks. That fixed the problem.. I have another problem though.. My ASP
programmer is telling me it is impossible for ADO to call a stored procedure
and get back an output variable and a recordset at the same time. She even
claims MSDN says so. I simply cannot believe this. I suggested the
following:

Set oCmd = CreateObject("A DODB.Command")

oCmd.ActiveConn ection = Application("ep icor_Connection String")

oCmd.CommandTex t = "PT_wspLoyaltyL ookUpByBillTo"

oCmd.CommandTyp e = adCmdStoredProc

oCmd.Parameters .Append
oCmd.CreatePara meter("@BillTo" ,adChar,adParam Input,8,custnum )

oCmd.Parameters .Append
oCmd.CreatePara meter("@ReturnC ode",adInteger, adParamOutput,, 0)

set rs = oCmd.Execute

vReturnCode = oCmd.Parameters ("@ReturnCod e")

response.write vReturnCode & " <font color='green'> : vReturnCode - s/b 1
</font> <br>"

response.write rs(0) & " <font color='green'> :: <<< if this is 18184 it is
good!</font> <br> <br>"

I simply cannot believe it's impossible to get back an output parameter and
a recordset.

Shaun
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:OY******** ******@TK2MSFTN GP14.phx.gbl...
Anytime you use

Server.CreateOb ject

MTS (COM+) is involved. If you do not want MTS to be involved, use
CreateObject (without the "Server.").

There is nothing intrinsic in the use of a Command object that causes MTS to be involved.

There are two ways to get output variables from your stored procedures:

Command object (recommended)
See your code

Dynamic SQL (not recommended)
sSQL = "declare @P1 int, @P2 int; Set @P1 = 0;" & _
"Set @P2=" & userinput & ";" & _
"exec someproc @P1 output, @P2;" & _
"SELECT @P1 As OutParm"
Set cn=createobject ("adodb.connect ion")
cn.open Application("on acctEpi_Connect ionString")
Set rs=cn.execute(s SQL,,1)

'if the procedure returned records, then process them here.
'then
Set rs = rs.NextRecordse t
outputparm = rs(0)
HTH,
Bob Barrows
Shaun Stuart wrote:
I've got a webpage that calls some stored procedures with input
variables. The procedures return recordsets and also some output
variables. We're trying to get the values of the output variables.
I've done this using the method I found in MSDN, as shown in the code
below. The problem is that we believe doing it this way involves the
use of the Microsoft Transaction Server (IIS transaction server). Is
this true? (The SQL Server and IIS Server are on different machines
and, I believe, a firewall separates them.)

I can't see why this method would use MTS. The problem is that in the
past, we have had problems with MTS stopping for no reason, which
causes the websites to not work. So my boss doesn't want to use any
ASP code that relies on MTS. Not using the stored procedure output
variables makes things way more complicated. So does this code really
invoke MTS? And if it does, is there a way to obtain SP output
variables without using MTS?

I am running SQL Server 7.0 with the latest service pack and IIS
version 4. We do have an IIS version 5 server we can use if that
matters.

Thanks,

Shaun
Set oCmd = Server.CreateOb ject("ADODB.Com mand")
oCmd.ActiveConn ection = Application("on acctEpi_Connect ionString")
oCmd.CommandTex t = "CPREP_GetRegio n"
oCmd.CommandTyp e = adCmdStoredProc

oCmd.Parameters .Append
oCmd.CreatePara meter("@locatio n",adVarChar,ad ParamInput,8,lo cationchoice) oCmd.Parameters .Append
oCmd.CreatePara meter("@method" ,adVarChar,adPa ramInput,8,frtc hoicecode)
oCmd.Parameters .Append
oCmd.CreatePara meter("@zip",ad VarChar,adParam Input,40,zipcod e)

oCmd.Parameters .Append
oCmd.CreatePara meter("@region" ,adVarChar,adPa ramOutput,8,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_cod e",adInteger,ad ParamOutput,,0)
oCmd.Parameters .Append
oCmd.CreatePara meter("@rtn_msg ",adVarChar,adP aramOutput,75,0 )

oCmd.Execute, ,adExecuteNoRec ords

region = oCmd.Parameters ("@region")
rtn_code = oCmd.Parameters ("@rtn_code" )
rtn_msg = oCmd.Parameters ("@rtn_msg")


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #5
Shaun Stuart wrote:
Thanks. That fixed the problem.. I have another problem though.. My
ASP programmer is telling me it is impossible for ADO to call a
stored procedure and get back an output variable and a recordset at
the same time. She even claims MSDN says so. I simply cannot believe
this. I suggested the following:


She's wrong. The only caveat is that all the records in the recordset must
be sent to the client before the return and output parameter values are
sent. In the case of a server-side recordset, you pretty much have to close
the recordset before reading the output and return parameters. With a
client-side cursor, they should be available right away.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #6
Ah! Now that you mention that, I do remember reading something along those
lines in MSDN. That solved the problem. Thanks for your help!!

Shaun
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:uy******** ******@tk2msftn gp13.phx.gbl...
Shaun Stuart wrote:
Thanks. That fixed the problem.. I have another problem though.. My
ASP programmer is telling me it is impossible for ADO to call a
stored procedure and get back an output variable and a recordset at
the same time. She even claims MSDN says so. I simply cannot believe
this. I suggested the following:

She's wrong. The only caveat is that all the records in the recordset must
be sent to the client before the return and output parameter values are
sent. In the case of a server-side recordset, you pretty much have to

close the recordset before reading the output and return parameters. With a
client-side cursor, they should be available right away.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #7

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

Similar topics

0
1389
by: Luis | last post by:
I'm using a SQL Server 2000 stored procedure similar to the one below to upload data to a database. This data is collected from the user on a number of asp pages and stored in session variables (that's the way I inherited the system...). When the user has captured all the info and clicks the submit button the stored procedure is called and it uploads the data to the database. This normally works perfectly except for a few occassions when...
3
393
by: Iain Mcleod | last post by:
I wish to do a series of inserts on a sql server database in the context of a transaction. The inserts will be done as a series of stored procedure calls. I wish to be able to rollback any inserts should one fail. A quick google on ".net transactions" and the following page comes up: http://samples.gotdotnet.com/quickstart/aspplus/doc/mtstransactions.aspx It says basically that the class System.EnterpriseServices.ContextUtil is the...
3
4651
by: Ace Calhoon | last post by:
Hello, I have a VBA/Database application which reads files, analyzes them, updates a database, and then moves them to an archive. I would like to make this an atomic transaction -- that is, if the move to the archive fails, I don't want the database to be updated (and if the database update fails, I don't want the file moved...) The logic I want is as follows: Begin transaction
3
4051
by: Irfan | last post by:
There are several ways of handling Transactions in DotNet. Some of them are 1. Using COM+ Serviced Component. 2. Using ADO .Net 3. using stored procedure What is the best way of handling Transaction in DotNet Enterprise Application interms of performance, maintainance and scalability? How feasible it would be if we go for stored procedure option, considering
11
12997
by: Mike P | last post by:
I've been using C# transactions for a while and had no problems with them. Using try catch blocks I can trap basically all possible errors and rollback all necessary data. Over the last few days I've been trying to convert some of this code to SQL Server stored procedures, but it seems to lack many of the benefits of C# transactions - a lot of the errors don't seem to be trapped by the SQL error trapping (e.g. if I do an update on a row...
5
1727
by: Andy G | last post by:
I have a registration page that captures 75% of the users data. After they enter that info they are redirected to one of two pages depending on how they answered a question on the registation page. My question is would it be better to store all of the fields(15 or so) from the first page in session variables and reference them from the next page and run ONE stored procedure OR would it be better to run a stored procedure the first page...
2
1874
by: RAM | last post by:
Hello, (Sorry for my English...) I am learning .NET 2.0 (C#, ASP.NET, ADO.NET etc.). I need to write a database application (SQL Server) consisting of a number of database transactions (like accounting system). Each of these transactions has enty in menu, parameters screen (.aspx page), some logic (probably implemented in code-behind), and results screen (could be same.aspx page). I need a good design, some ideas of experienced...
8
1678
by: amoldiego | last post by:
Hi friends, I am using stuts,oracle(stored procedure),jsp in my application. i have done all thing like writing stored procedure ,inserting data,validating data etc and finally data goes inside database. But friends my problem is that when i do two simultanious transaction in aplication then both trasaction are inserted into databases without giving me any exception which i expect from second transaction. for example Suppose
0
3192
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works fine. Now we decided to move from mainframe IMS-DB2 to Windows 2003 server-DB2 UDB for LUW 9.5.
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7403
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.