Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Too many clients .... NEVER hahahahaaa


Message #1 by mdehnel@a... on Thu, 28 Jun 2001 05:27:28
Error



Microsoft OLE DB Provider for ODBC Drivers error '80040e4d' 



[Microsoft][ODBC Microsoft Access Driver] Too many client tasks. 



/pages/tools.asp, line 9 



What or Who limits the number of connections to a DB, is this a server 

issue.

I think I am closing everyting.  Do I also need to set objects = Nothing?

What is the magic limit number can I set it greater?.

Do I have to wait for sessions to time out now on the server?

can I kill the errant client apps?



Thanks many times over, I will keep looking, I told myself I can't go to 

bed until I figure this out...





from login page ...



<%

If Request("login")<>"" Then

'  OpenDNSlessAdr con

  OpenAddress con

  If CheckLogin(Request("UserName"),Request("Password")) Then

    Session("sessionUser")=Request("UserName")

    Session("sessionValid") = "True"

    Session("sessionClientTime") = Request.Form("myHiddenField")

    Response.Redirect "pages/master.asp"

  End If

End If

%>



Additional Subs...



<%

'--- This function opens database connection

Sub OpenAddress(ByRef con)

  Set con = Server.CreateObject("ADODB.Connection")

  con.Open "DSN=mydatabase"                           '<----------- Line 9

End Sub



'--- Check login

Function CheckLogin(n,p)

'--- CheckLogin = False

  Session("Admin") = ""

  SQL = "SELECT * FROM Players WHERE fldUserName = '" & n & _

    "' AND fldPlyrPW = '" & p & "'"

  Set rs = con.Execute(SQL)

  If Not rs.EOF Then

    Session("Admin") = rs("PlayerID")

    LogUser Session("Admin"), "yes"

    CheckLogin = True

  else

    Session("Admin") = n

    LogUser Session("Admin"), "no"

    CheckLogin = False

  End If

  rs.Close

  con.Close

End Function



'--- log user into database

Sub LogUser(u, pf)

  l = "INSERT INTO tblLog (fldUserName,fldTimeIn,fldDate,fldSuccessful) 

VALUES ('" & u & "',#" & Time() & "#,#" & Date() & "#," & pf & ")"

  con.Execute(l)

End Sub



%>



Message #2 by "Ken Schaefer" <ken@a...> on Thu, 28 Jun 2001 19:29:53 +1000
Do you have many implicit connections?

How many times are you calling the sub that creates the connection?

Theoretically you should have to call it once only in a page, but looking at

your other subs, it seems like you might be calling it several times...



Yes, you should set your objects to Nothing. Everything you Set, you should

Set = Nothing

Use a sub to do that as well:



<%

' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

' Accepts ADO object as input param

' Attempts to close object if object is adStateOpen

' Attempts to set object to nothing if isObject

' Handles errors internally

' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



Sub subADOClose( _

    ByRef objToClose _

    )



    On Error Resume Next



    If objToClose.State = adStateOpen then

        objToClose.Close

    End IF



    If isObject(objToClose) then

        Set objToClose = Nothing

    End If



End Sub

%>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: <mdehnel@a...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, June 28, 2001 5:27 AM

Subject: [asp_databases] Too many clients .... NEVER hahahahaaa





: Error

:

: Microsoft OLE DB Provider for ODBC Drivers error '80040e4d'

:

: [Microsoft][ODBC Microsoft Access Driver] Too many client tasks.

:

: /pages/tools.asp, line 9

:

: What or Who limits the number of connections to a DB, is this a server

: issue.

: I think I am closing everyting.  Do I also need to set objects = Nothing?

: What is the magic limit number can I set it greater?.

: Do I have to wait for sessions to time out now on the server?

: can I kill the errant client apps?

:

: Thanks many times over, I will keep looking, I told myself I can't go to

: bed until I figure this out...

:

:

: from login page ...

:

: <%

: If Request("login")<>"" Then

: '  OpenDNSlessAdr con

:   OpenAddress con

:   If CheckLogin(Request("UserName"),Request("Password")) Then

:     Session("sessionUser")=Request("UserName")

:     Session("sessionValid") = "True"

:     Session("sessionClientTime") = Request.Form("myHiddenField")

:     Response.Redirect "pages/master.asp"

:   End If

: End If

: %>

:

: Additional Subs...

:

: <%

: '--- This function opens database connection

: Sub OpenAddress(ByRef con)

:   Set con = Server.CreateObject("ADODB.Connection")

:   con.Open "DSN=mydatabase"                           '<----------- Line 9

: End Sub

:

: '--- Check login

: Function CheckLogin(n,p)

: '--- CheckLogin = False

:   Session("Admin") = ""

:   SQL = "SELECT * FROM Players WHERE fldUserName = '" & n & _

:     "' AND fldPlyrPW = '" & p & "'"

:   Set rs = con.Execute(SQL)

:   If Not rs.EOF Then

:     Session("Admin") = rs("PlayerID")

:     LogUser Session("Admin"), "yes"

:     CheckLogin = True

:   else

:     Session("Admin") = n

:     LogUser Session("Admin"), "no"

:     CheckLogin = False

:   End If

:   rs.Close

:   con.Close

: End Function

:

: '--- log user into database

: Sub LogUser(u, pf)

:   l = "INSERT INTO tblLog (fldUserName,fldTimeIn,fldDate,fldSuccessful)

: VALUES ('" & u & "',#" & Time() & "#,#" & Date() & "#," & pf & ")"

:   con.Execute(l)

: End Sub

:

: %>

:





Message #3 by mdehnel@a... on Thu, 28 Jun 2001 13:52:00
This is very well writen and clean I might add.  I have made a promise to myself that after I resolve
this 

problem and finsh the functionality of this page I will not continue until all of my code look this good and 

is commented too.



Q1:  The code that I listed is all that is run to the point of the error.  Is there a persistance issue with 

other sessions lingering as I try code.  Nothing: does this kill the thread as well as free memory or is 

there another method that is more suited along with nothing I should issue.  At least while I am 

debugging the application



Q2: I was not getting any of these errors on my development maching running PWS and with a different

DNSless con.open string.  It was only after I moved the app to my server that this came up.  That is 

why I was wondering if it was a server issue and what limits are placed on Access databases for number 

of open clinets.



I will add this sub and check the rest of code to make sure that I am closing objects



> Do you have many implicit connections?

> How many times are you calling the sub that creates the connection?

> Theoretically you should have to call it once only in a page, but looking 

at

> your other subs, it seems like you might be calling it several times...

> 

> Yes, you should set your objects to Nothing. Everything you Set, you 

should

> Set = Nothing

> Use a sub to do that as well:

> 

> <%

> ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

> ' Accepts ADO object as input param

> ' Attempts to close object if object is adStateOpen

> ' Attempts to set object to nothing if isObject

> ' Handles errors internally

> ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

> 

> Sub subADOClose( _

>     ByRef objToClose _

>     )

> 

>     On Error Resume Next

> 

>     If objToClose.State = adStateOpen then

>         objToClose.Close

>     End IF

> 

>     If isObject(objToClose) then

>         Set objToClose = Nothing

>     End If

> 

> End Sub

> %>

> 


  Return to Index