Random connection pb with ASP and Access

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Random connection pb with ASP and Access

    Hello,

    My asp web site is based on MS Access to get the login and password.
    It works fine in the test environment, but randomly fails in production
    (works fine, once, but if I come back five minutes later, it redirects to
    the error login page with the same correct username and password., then five
    minutes later, works fine again...)
    In IIS5 log, I have sc-status 302 and 500 ?!?
    Should I start a pool connexion, would that help ? This is very wired...
    Thanks in advance for your ideas
    Fred


    Fred Guest

  2. Similar Questions and Discussions

    1. random records from Access?
      Hi I'm using a Windows 2003 server an access database, with ODBC connection Is there anywhere I can find info about displaying all records in...
    2. random order results from MS access database
      simple question but how could I go about order by search results randomly every time the page loads, or even better set it up so that each time the...
    3. ASP DSN-less connection to Access
      Dear All, I have IIS running on Windows XP Pro. On the server is a Access database and my ASP pages all under the 'wwwroot folder'. I have a...
    4. Access DB Connection problems
      Ok, I'm pretty new to this, so please be patient. Here the story. I've got a very simple access database used for people to enroll in training...
    5. ASP & Access connection
      Hi, Is it possible to connect to Access file located on another web server using ASP 3.0? Thanx, Neven
  3. #2

    Default Re: Random connection pb with ASP and Access

    hello,

    is your connexion object in the session pool or application one ?
    acceess will fails if you try to connect 2 connections in R/W mode in the
    same time.
    try with an application level connection.

    "Fred" <back@boursorama.com> a écrit dans le message de
    news:ukfmPUXcDHA.1540@tk2msftngp13.phx.gbl...
    > Hello,
    >
    > My asp web site is based on MS Access to get the login and password.
    > It works fine in the test environment, but randomly fails in production
    > (works fine, once, but if I come back five minutes later, it redirects to
    > the error login page with the same correct username and password., then
    five
    > minutes later, works fine again...)
    > In IIS5 log, I have sc-status 302 and 500 ?!?
    > Should I start a pool connexion, would that help ? This is very wired...
    > Thanks in advance for your ideas
    > Fred
    >
    >

    Martin CLAVREUIL Guest

  4. #3

    Default Re: Random connection pb with ASP and Access


    Thank you Martin for your quick answer.

    Here is how I manage the access (Thru an ODBC connexion to MS Access,
    the connexion pool is not activated, should I ?). For your information,
    the try to connect are not simultaneous. Sometimes, the users can log
    for 15 minutes, and the suddenly, it doesn't work anymore for some time,
    and then, it works again...
    Thank you for your help. I'm becoming crazy...
    Regards
    Fred

    // *** Validate request to log in to this site.
    var MM_LoginAction = Request.ServerVariables("URL");
    if (Request.QueryString!="") MM_LoginAction += "?" +
    Request.QueryString;
    var MM_valUsername=String(Request.Form("txtUtilisateur "));
    if (MM_valUsername != "undefined") {
    var MM_fldUserAuthorization="niveau_acces";
    var MM_redirectLoginSuccess="accueil_utilisateur.asp";
    var MM_redirectLoginFailed="erreur_identification.asp" ;
    var MM_flag="ADODB.Recordset";
    var MM_rsUser = Server.CreateObject(MM_flag);
    MM_rsUser.ActiveConnection = MM_Administrateur_STRING;
    MM_rsUser.Source = "SELECT nom_utilisateur, password";
    if (MM_fldUserAuthorization != "") MM_rsUser.Source += "," +
    MM_fldUserAuthorization;
    MM_rsUser.Source += " FROM responsable WHERE nom_utilisateur='" +
    MM_valUsername + "' AND password='" +
    String(Request.Form("txtMotdePasse")) + "'";
    MM_rsUser.CursorType = 0;
    MM_rsUser.CursorLocation = 2;
    MM_rsUser.LockType = 3;
    MM_rsUser.Open();
    if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
    // username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername;
    if (MM_fldUserAuthorization != "") {
    Session("MM_UserAuthorization") =
    String(MM_rsUser.Fields.Item(MM_fldUserAuthorizati on).Value);
    } else {
    Session("MM_UserAuthorization") = "";
    }
    if (String(Request.QueryString("accessdenied")) != "undefined" &&
    false) {
    MM_redirectLoginSuccess = Request.QueryString("accessdenied");
    }
    MM_rsUser.Close();
    Response.Redirect(MM_redirectLoginSuccess);
    }
    MM_rsUser.Close();
    Response.Redirect(MM_redirectLoginFailed);
    }


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Frederic BACK Guest

  5. #4

    Default Re: Random connection pb with ASP and Access

    Sorry, but - never use an application-level connection:

    [url]http://www.learnasp.com/learn/sessionoverview.asp[/url]
    [url]http://www.learnasp.com/advice/dbsessionapp.asp[/url]
    [url]http://www.learnasp.com/learn/globalproblems.asp[/url]
    [url]http://www.learnasp.com/learn/stateproscons.asp[/url]

    OLEDB implements connection pooling. There is no need to serialize database
    access by tying all users to a single database connection.

    Bob Barrows

    "Martin CLAVREUIL" <martin.clavreuil@wanadoo.fr> wrote in message
    news:O7yahxccDHA.2672@tk2msftngp13.phx.gbl...
    > hello,
    >
    > is your connexion object in the session pool or application one ?
    > acceess will fails if you try to connect 2 connections in R/W mode in the
    > same time.
    > try with an application level connection.
    >
    > "Fred" <back@boursorama.com> a écrit dans le message de
    > news:ukfmPUXcDHA.1540@tk2msftngp13.phx.gbl...
    > > Hello,
    > >
    > > My asp web site is based on MS Access to get the login and password.
    > > It works fine in the test environment, but randomly fails in production
    > > (works fine, once, but if I come back five minutes later, it redirects
    to
    > > the error login page with the same correct username and password., then
    > five
    > > minutes later, works fine again...)
    > > In IIS5 log, I have sc-status 302 and 500 ?!?
    > > Should I start a pool connexion, would that help ? This is very wired...
    > > Thanks in advance for your ideas
    > > Fred
    > >
    > >
    >
    >

    Bob Barrows Guest

  6. #5

    Default Re: Random connection pb with ASP and Access

    Very tough to troubleshoot without seeing code ...

    "Fred" <back@boursorama.com> wrote in message
    news:ukfmPUXcDHA.1540@tk2msftngp13.phx.gbl...
    > Hello,
    >
    > My asp web site is based on MS Access to get the login and password.
    > It works fine in the test environment, but randomly fails in production
    > (works fine, once, but if I come back five minutes later, it redirects to
    > the error login page with the same correct username and password., then
    five
    > minutes later, works fine again...)
    > In IIS5 log, I have sc-status 302 and 500 ?!?
    > Should I start a pool connexion, would that help ? This is very wired...
    > Thanks in advance for your ideas
    > Fred
    >
    >

    Bob Barrows Guest

  7. #6

    Default Re: Random connection pb with ASP and Access

    You do not seem to be handling failures to connect to the database, so it is
    unclear whether the problem is database connectivity, or another problem
    such as losing session variable values, or failing to pass the correct
    querystring value, or something else entirely.

    You should be explicitly creating and opening a Connection object rather
    than setting the recordset's activeconnection property to a connection
    string. This will allow you to catch any error that occur when opening the
    connection using Try.

    I'm not familiar enough with javascript to suggest improvements. Hopefully
    someone else can jump in.

    See inline response:
    "Frederic BACK" <back@boursorama.com> wrote in message
    news:u3rjQ$dcDHA.2432@TK2MSFTNGP10.phx.gbl...
    >
    > Thank you Martin for your quick answer.
    >
    > Here is how I manage the access (Thru an ODBC connexion to MS Access,
    > the connexion pool is not activated, should I ?). For your information,
    > the try to connect are not simultaneous. Sometimes, the users can log
    > for 15 minutes, and the suddenly, it doesn't work anymore for some time,
    > and then, it works again...
    > Thank you for your help. I'm becoming crazy...
    > Regards
    > Fred
    >
    > // *** Validate request to log in to this site.
    > var MM_LoginAction = Request.ServerVariables("URL");
    > if (Request.QueryString!="") MM_LoginAction += "?" +
    > Request.QueryString;
    > var MM_valUsername=String(Request.Form("txtUtilisateur "));
    > if (MM_valUsername != "undefined") {
    > var MM_fldUserAuthorization="niveau_acces";
    > var MM_redirectLoginSuccess="accueil_utilisateur.asp";
    > var MM_redirectLoginFailed="erreur_identification.asp" ;
    > var MM_flag="ADODB.Recordset";
    > var MM_rsUser = Server.CreateObject(MM_flag);
    > MM_rsUser.ActiveConnection = MM_Administrateur_STRING;
    > MM_rsUser.Source = "SELECT nom_utilisateur, password";
    > if (MM_fldUserAuthorization != "") MM_rsUser.Source += "," +
    > MM_fldUserAuthorization;
    > MM_rsUser.Source += " FROM responsable WHERE nom_utilisateur='" +
    > MM_valUsername + "' AND password='" +
    > String(Request.Form("txtMotdePasse")) + "'";
    > MM_rsUser.CursorType = 0;
    > MM_rsUser.CursorLocation = 2;
    > MM_rsUser.LockType = 3;
    > MM_rsUser.Open();
    > if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
    This statement does not seem to be correct. You should be using a logical
    AND (&&) here, not OR (||). You want both EOF and BOF to be false, not just
    one or the other. Actually, since you've just opened the recordset, all you
    need to check for is EOF, since a recordset will always be pointing at the
    first record if it has records immediately after opening.


    Bob Barrows


    Bob Barrows Guest

  8. #7

    Default Re: Random connection pb with ASP and Access

    See my other response. You have no way of knowing from this code whether the
    redirect is due to a database connection failure, or some other cause.

    Bob Barrows
    Frederic BACK wrote:
    > Sorry Bob, here are some other elements.
    > I added in my code "response.buffer=true" Do you think it might help ?
    >
    > Here is how I manage the access (Thru an ODBC connexion to MS Access,
    > the connexion pool is not activated, should I ?). For your
    > information, the try to connect are not simultaneous. Sometimes, the
    > users can log for 15 minutes, and the suddenly, it doesn't work
    > anymore for some time, and then, it works again...
    > Thank you for your help. I'm becoming crazy...
    > Regards
    > Fred
    > <%@LANGUAGE="JAVASCRIPT"%>
    > <!--#include file="Connections/Administrateur.asp" -->
    > <%
    > // *** Validate request to log in to this site.
    > Response.buffer = true;
    > var MM_LoginAction = Request.ServerVariables("URL");
    > if (Request.QueryString!="") MM_LoginAction += "?" +
    > Request.QueryString;
    > var MM_valUsername=String(Request.Form("txtUtilisateur "));
    > if (MM_valUsername != "undefined") {
    > var MM_fldUserAuthorization="niveau_acces";
    > var MM_redirectLoginSuccess="accueil_utilisateur.asp";
    > var MM_redirectLoginFailed="erreur_identification.asp" ;
    > var MM_flag="ADODB.Recordset";
    > var MM_rsUser = Server.CreateObject(MM_flag);
    > MM_rsUser.ActiveConnection = MM_Administrateur_STRING;
    > MM_rsUser.Source = "SELECT nom_utilisateur, password";
    > if (MM_fldUserAuthorization != "") MM_rsUser.Source += "," +
    > MM_fldUserAuthorization;
    > MM_rsUser.Source += " FROM responsable WHERE nom_utilisateur='" +
    > MM_valUsername + "' AND password='" +
    > String(Request.Form("txtMotdePasse")) + "'";
    > MM_rsUser.CursorType = 0;
    > MM_rsUser.CursorLocation = 2;
    > MM_rsUser.LockType = 3;
    > MM_rsUser.Open();
    > if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
    > // username and password match - this is a valid user
    > Session("MM_Username") = MM_valUsername;
    > if (MM_fldUserAuthorization != "") {
    > Session("MM_UserAuthorization") =
    > String(MM_rsUser.Fields.Item(MM_fldUserAuthorizati on).Value);
    > } else {
    > Session("MM_UserAuthorization") = "";
    > }
    > if (String(Request.QueryString("accessdenied")) != "undefined" &&
    > false) {
    > MM_redirectLoginSuccess = Request.QueryString("accessdenied");
    > }
    > MM_rsUser.Close();
    > Response.Redirect(MM_redirectLoginSuccess);
    > }
    > MM_rsUser.Close();
    > Response.Redirect(MM_redirectLoginFailed);
    > }
    >
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Bob Barrows Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139