# Miscellaneous > Database Programming >  Linked Access Tables and ASP

## Karen

I have 2 databases with tables, I have created a 3rd database with the linked tables I need from the 1st two databases.  Is there a problem when accessing linked tables. I get a &#34;database opened exclusively&#34; error when I use connection for 3rd DB, if I connect to DB live(no linked tables) that gives me the error, it works. Here is code I have:

<%@ LANGUAGE=VBScript %>
<%
Param = Request.QueryString(&#34;Param&#34 :Wink: 
Data = Request.QueryString(&#34;Data&#34 :Wink: 
%>

<%
&#39; Check to see if user has logged on
If Session(&#34;bmk_Trainee&#34 :Wink: =&#34;Invalid&#34;  or Session(&#34;bmk_Trainee&#34 :Wink:  = &#34;&#34; Then
	Response.Redirect &#34;Default.asp&#34;
	Response.End
End if

&#39;Open data connection from logon
If IsObject(Session(&#34;Conn&#34 :Wink: ) Then
	Set Conn = Session(&#34;Conn&#34 :Wink: 
Else
	Set Conn = Server.CreateObject(&#34;ADODB.connection&#34 :Wink: 
	Conn.ConnectionTimeout = Session(&#34;AbbRadWeb_ConnectionTimeout&#34 :Wink:  
	Conn.CommandTimeout = Session(&#34;AbbRadWeb_CommandTimeout&#34 :Wink:  

	strConnString = Session(&#34;AbbRadWeb_ConnectionString&#34 :Wink: 
	strUsername = Session(&#34;AbbRadWeb_RuntimeUserName&#34 :Wink: 
	strPassword= Session(&#34;AbbRadWeb_RuntimePassword&#34 :Wink: 

	Conn.open strConnString, strUsername, strPassword
End if
&#39; Store session variables
bmk_Trainee = Session(&#34;bmk_Trainee&#34 :Wink: 
UserName = Session(&#34;UserName&#34 :Wink: 
%>
<%
    Set rs = Server.CreateObject(&#34;ADODB.recordset&#34 :Wink: 
    strsql = &#34;SELECT qrptGlobalInventory.* FROM qrptGlobalInventory;&#34;
    rs.Open strsql, Conn
%>

Thanks

----------


## John

Hi Karen,

I&#39;m not sure how this relates to ASP-db.  I don&#39;t see any calls to it in your example code.  ASP-db manages all the connectsion for you and doesn&#39;t store them in session variables so you won&#39;t have this problem with databases being opened &#34;exclusively&#34;, etc.

That said, your problem probably revolves around the fact that you&#39;re storing your connection objects in session variables.  According to the Microsoft experts we&#39;ve talked to, that&#39;s a no-no.  Their advice is, &#34;Open it, read it, close it, and get out!&#34;.  They don&#39;t recommend it because of the kinds of problems you get into with &#34;exclusive&#34; locking, and more importantly because of the excessive resources that you&#39;ll eat up on the server doing so.  After only a few dozen users, your server will run out of handles, memory, licenses, etc.  It&#39;s fine to store things in session variables, but try to avoid storing data connections or recordsets there.

Hope this helps,

John


On 11/16/98 3:00:08 PM, Karen wrote: 
> I have 2 databases with tables, I have created a 3rd database with the 
> linked tables I need from the 1st two databases.  Is there a problem when 
> accessing linked tables. I get a &#34;database opened exclusively&#34; 
> error when I use connection for 3rd DB, if I connect to DB live(no linked 
> tables) that gives me the error, it works. Here is code I have:

<%@ 
> LANGUAGE=VBScript %>
<%
Param = 
> Request.QueryString(&#34;Param&#34 :Wink: 
Data = 
> Request.QueryString(&#34;Data&#34 :Wink: 
%>

<%
&#39; Check to see if user 
> has logged on
If Session(&#34;bmk_Trainee&#34 :Wink: =&#34;Invalid&#34;  or 
> Session(&#34;bmk_Trainee&#34 :Wink:  = &#34;&#34; Then
	Response.Redirect 
> &#34;Default.asp&#34;
	Response.End
End if

&#39;Open data connection 
> from logon
If IsObject(Session(&#34;Conn&#34 :Wink: ) Then
	Set Conn = 
> Session(&#34;Conn&#34 :Wink: 
Else
	Set Conn = 
> Server.CreateObject(&#34;ADODB.connection&#34 :Wink: 
	Conn.ConnectionTimeout = 
> Session(&#34;AbbRadWeb_ConnectionTimeout&#34 :Wink:  
	Conn.CommandTimeout = 
> Session(&#34;AbbRadWeb_CommandTimeout&#34 :Wink:  

	strConnString = 
> Session(&#34;AbbRadWeb_ConnectionString&#34 :Wink: 
	strUsername = 
> Session(&#34;AbbRadWeb_RuntimeUserName&#34 :Wink: 
	strPassword= 
> Session(&#34;AbbRadWeb_RuntimePassword&#34 :Wink: 

	Conn.open strConnString, 
> strUsername, strPassword
End if
&#39; Store session 
> variables
bmk_Trainee = Session(&#34;bmk_Trainee&#34 :Wink: 
UserName = 
> Session(&#34;UserName&#34 :Wink: 
%>
<%
    Set rs = 
> Server.CreateObject(&#34;ADODB.recordset&#34 :Wink: 
    strsql = &#34;SELECT 
> qrptGlobalInventory.* FROM qrptGlobalInventory;&#34;
    rs.Open strsql, 
> Conn
%>

Thanks

----------

