Solved

Datbase connections and ASP

Posted on 1998-09-08
15
326 Views
Last Modified: 2013-12-25
I am running ASP and an SQL-server. I have set simultanious calls to 15 and the timeout to 30 min. My problem is that since it is a quite big intranet, there is often more than 15 ppl who visits the same page within 30 minutes. In global.asa I have declared:

Set Session("Databas") = Server.CreateObject("ADODB.Connection")
    Session("Databas").Open "DSN=SQL_intranet;UID=xxx;PWD=xxx;APP=MSDS;WSID=AWE1;LANGUAGE=us_english;DATABASE=SQLData_Intranet"

And then, when accessing the database I use:

xxxx = Session("Databas").Execute(string)

and when done I use:
xxxx.close
Set xxxx = Nothing

What can I do to end the database call. I tried closing the "databas" session but that only leads to an error message when I go to another ASP page.
0
Comment
Question by:aspdev
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
15 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 100 total points
ID: 1854812
You can change the timeout in your scripts. If your problem is that too many unused connections are running then try this:

<%
Server.ScriptTimeOut = 5
%>

Also you can get rid of the global.asa. It is not really necessary. And I do not use it at all.
What I do is making a file called "Connect.inc", which creates the connection object, and which is included in each page where it is needed, ussing SSI.

Connect.inc:

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.ConnectionTimeout = 15
Conn.CommandTimeout = 30
Conn.Open "DNS=MyDNS"
%>

As you see you can change the ConnectionTimeout and the CommandTimeout. They are given in minutes.


0
 

Author Comment

by:aspdev
ID: 1854813
The thing is that in the morning, alot of people connect to the intranet at the same time. So lowering the timeout wouldn't be sufficient.
Raising the maximum amount of simultanious connection isn't an good option since that would slow down the intranet.

What I need to happen is that when the data has been exctracted, the connection is dropped but without loosing the value if the Session-variables.

What is the diffrence between global.asa and Connect.inc other than that global.asa doeasn't have to be included in each page?

What happens when the connection is closed due to timeout. Which data is lost (all sesssion variables?) etc.
0
 
LVL 28

Expert Comment

by:sybe
ID: 1854814
You can close the connection by:
<%
Conn.close
%>
So you can close the connection object in each page when you don't need it.
SessionVariables are not lost then, with a strange exception in Netscape and Redirecting the user.
For some strange reason I have found several times that Netscape loses the SessionVariables with this code:
<%
Conn.close
Response.redirect("anotherpage.asp")
%>
But it does not happen consistently.

There's not a real difference between Global.asa and connect.inc, only that I like to know exactly what is going on. Connect.inc is more flexible, 'cause I can give part of the application another connection when I am testing.

0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

Author Comment

by:aspdev
ID: 1854815
I have, on the page in question, added the code you suggested for the Connect.inc file. Then, at the end of the page, I close the connection with Conn.Close

I figured that by opening a "extra" connection for this page and then closing it imediately, I would first of all get rid of the open connection. (unless >15 ppl decide to update the page at once...
Second, I don't affect the other connection from other pages called by the one declared in global.asa.

Does this sound like a good idea or is there something I'm overlooking?
0
 

Author Comment

by:aspdev
ID: 1854816
Hmmm... there must be something I'm missing...

It worked fine for a while, and then I got the same error again; To many conections... strange...
0
 

Author Comment

by:aspdev
ID: 1854817
What I can come to think of is this:
Whenever someone loads an ASP page. the global.asa opens a connection to the SQL-server. This leads to the fact that no more than 15 persons can access an asp page within 30 minutes.

This would also be true for the "Conn"-connection.
But why does it say that more than 15 is connected if I, at the end of the page, CLOSE the connnection with Conn.close?
0
 
LVL 28

Expert Comment

by:sybe
ID: 1854818
I am not sure how Conn.Close and global.asa react. That is why I use connect.inc.
Maybe you should add also
Conn = null
after closing the connection


0
 

Author Comment

by:aspdev
ID: 1854819
Ok. Trying that....
Btw, is it possible to have f.i. "0.5" as timeout? and, can it timeout while beeing used, i.o.w. during the time the page is loading?
0
 
LVL 28

Expert Comment

by:sybe
ID: 1854820
Hmm, I don't know the answers to your questions. But it worth trying it out.

0
 

Author Comment

by:aspdev
ID: 1854821
I tried setting both the timeouts to 1 minute.
and I still close the connection at the end of the page.
All this lead to that the evrything worked fine for more than an hour (doubled the last error time, atleast) but in the end, I got the same "to many conncetions" message again...
0
 
LVL 28

Expert Comment

by:sybe
ID: 1854822
Why don't you set the simultanious calls much higher ?
0
 

Author Comment

by:aspdev
ID: 1854823
SInce that would slow down the server and also, would mean that I'd have to buy a new license. Though, I'm installing IIS4 nex week with netwok license and on a new mashine so I'll be able to do both after that.

Do you still get comments if I add one later, even if I accept your answer?
I mean, I want to give you the point's, you sure are worth them. But, what if the problem comes up again as soon as I start the new server...

Oh well, just reply to this and I'll give you the points!

Thanx for all your help!

/MÕrten
0
 

Author Comment

by:aspdev
ID: 1854824
Sybe? You don't want the points?
0
 
LVL 28

Expert Comment

by:sybe
ID: 1854825
yes, I want the points, of course :)

And yes, I still get comments, even when the question is PAQ.

0
 

Author Comment

by:aspdev
ID: 1854826
Here you go! 100 pts for you, and wow, you don't even have to share ;)

The problem isn't really solved but I'll wait till we have the new server up and running.

Btw, do you know the diffrence between close and abandon? figured abandon could be used with better result maybe?
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question