Active Server Pages and SQL Server Transactions

Active Server Pages and SQL Server Transactions

Post by Robin Sha » Fri, 27 Feb 1998 04:00:00



I am trying to create a SQL Server transaction using VBScript on an Active
Server Page.

Session("DBConn").BeginTrans

However, I get the following error message

"Cannot start transaction because more than one hdbc is in use. "

Can anyone explain it to me please.

Thanks in Advance

Robin
Aberdeen
Scotland

 
 
 

Active Server Pages and SQL Server Transactions

Post by Rasanen [MVP » Fri, 27 Feb 1998 04:00:00


Robin,

From Inside ODBC, Ch. 5

A connection handle manages all information about a connection. From a
driver writers perspective, this means that a connection handle is used to
keep track of a network connection to a server or alternatively to keep
track of directory and file information if the local file system is the
source of data.

From the Driver Managers perspective, a connection handle is used to
identify the driver used in the connection and for all routing of function
calls. Using the Windows naming scheme, a connection handle is referred to
as an hdbc (handle to a database connection).

An hdbc is allocated with a function call that associates it with the
environment handle: SQLAllocConnect(henv, &hdbc). It is deallocated with the
SQLFreeConnect function. The Driver Manager stores the hdbc inside the data
structure referenced by the henv. In fact, because multiple connection
handles can be allocated, the Driver Manager actually keeps a list of
connection handles associated with the environment handle.

After the hdbc is allocated, it can be used to make a connection. The
connection handle stores the array of function pointers for a specific
driver.

After the connection function has successfully completed, the driver is
loaded into memory. Now the driver has a connection to the database server
and is ready to process SQL statements. At this point we say the hdbc is in
an active or a connected state, to distinguish it from an hdbc that is in an
allocated state.

Keep in mind that the connection process causes the Driver Manager to pass
to the driver the requests to allocate an environment handle and a
connection handle, so allocation of the drivers environment and connection
handles does not happen at the same time that it happens in the application
but when the application calls SQLConnect or another connection function.
For every ODBC function that is called, the Driver Manager will look up the
corresponding entry point in the array of function pointers stored in the
connection handle and make an indirect call to the driver.
In addition to storing the overall connection context information, a
connection handle is used for the following purposes in the ODBC API:

To establish a connection using SQLConnect, SQLDriverConnect, or
SQLBrowseConnect, and to break the connection using SQLDisconnect.
To pass to SQLError any errors that occur at the connection level, such as
the failure to load a driver, the failure to connect to the server across
the network, all communication errors (for example, network or wide area
network connection drops), the expiration of a connection time-out, the
attempt to use a connection already in use, and so forth.
To set connection options such as time-outs, transaction isolation levels,
and other options that are set using the SQLSetConnectOption function.
As the main transaction management handle. The context of a transaction is
determined by the hdbc. That is, the set of all the statements associated
with an hdbc constitutes the scope of the transaction. Although the
SQLTransact function can be used with an environment handle, as discussed in
the previous section, it is most often used with a connection handle.
As an argument of the informational functions SQLGetInfo and
SQLGetFunctions, which return information about the driver, data source, and
connection associated with the hdbc. A third informational function,
SQLNativeSQL, uses the hdbc to return SQL strings to an application,
translating escape clauses (see section 5.8.2.3) to DBMS-specific syntax and
performing other transformations.

--

Web Site: http://home.sprynet.com/sprynet/rasanen/
~
American Express TRS #265349


>I am trying to create a SQL Server transaction using VBScript on an Active
>Server Page.

>Session("DBConn").BeginTrans

>However, I get the following error message

>"Cannot start transaction because more than one hdbc is in use. "

>Can anyone explain it to me please.

>Thanks in Advance

>Robin
>Aberdeen
>Scotland


 
 
 

1. Java Server Pages/Servelets vs Active Server Pages

As a learning project, I'm planning a simple database-enabled website (a
file archive with keyword searches).

I looked today at the page for Microsoft's Site Server.  I'm a long-time
hater of Microsoft, but I must admit their product description makes it
sound very easy to do everything I'd need to do.  Would someone care to
contrast it to using Java Servelets/Pages/Beans/EJB?

Thanks for any advice!

-Richard

2. New Recordset and Closed Recordset

3. Weird Error connecting to SQL Server from Active Server Pages

4. Changing data/log file size thru SQLDMO

5. SQL Server Authentication via Active Server Pages

6. locking

7. Display an Image from SQL Server 7 in an Active Server Page

8. Scrolling within certain screens

9. Help: SQL Server 7 Cluster Server with Active/Active setup

10. Converting Active/Active to Active/Passive on SQL Server 7.0

11. Active Server Page (ASP) SQL Display

12. Active Server Pages/ SQL logon failure

13. SQL & Active Server pages