Inconsistent Yes/No In Access DB

Results 1 to 4 of 4

Thread: Inconsistent Yes/No In Access DB

  1. #1
    alphadog Guest

    Default Inconsistent Yes/No In Access DB

    Okay, this is frustrating. I have a form, main.asp, that feeds its contents into form, validate.asp. The latter form uses one variable, NPID, given by the first form to retrieve the value of a &#039;yes/no&#039; field in a table in an Access DB and is then supposed to then issue an update query to &#039;toggle&#039; it to its opposing value. (script at end)<BR><BR>Here&#039;s the weird part. Most times, when I come from main.asp, the wrong query is issued. Sounds like a bad conditional, right? Well, when I use validate.asp directly with the NPID in the URL, it works everytime. When I refresh validate.asp, therefore using the "same" form content having come from main.asp, it works everytime. Coming straight from main. asp, I get the error. Sometimes it works the first time, but not subsequent times when I return to main.asp and try another validate toggle.<BR><BR>How can coming from one page to another affect the querying of a db? Is there some sort of caching going on? Can anyone help me? It&#039;s driving me nuts.<BR><BR>--(validate.asp)-----------------------------<BR> Set rst = Server.CreateObject("ADODB.Recordset")<BR> sql = "SELECT Validated FROM tblNP WHERE NPID=" & Request("npid")<BR> Response.Write "first sql: " & sql <BR> rst.Open sql, con<BR> sql = ""<BR> If Not rst.EOF Then<BR> Response.Write "Validated: " & rst("Validated")<BR> If rst("Validated") Then <BR> sql = "UPDATE tblNP SET tblNP.Validated = False WHERE NPID=" & Request("npid")<BR> Else<BR> sql = "UPDATE tblNP SET tblNP.Validated = True WHERE NPID=" & Request("npid")<BR> End If<BR> End If<BR> rst.close<BR> Set rst = nothing<BR><BR> If Not sql= "" Then<BR> Set cmd = Server.CreateObject("ADODB.Command")<BR> cmd.ActiveConnection = con<BR> cmd.CommandType = 1<BR> cmd.CommandText = sql<BR> Response.Write "second sql: " & sql<BR> cmd.Execute<BR> End If<BR><BR> con.close<BR> Set con = nothing

  2. #2
    J.A.M Guest

    Default RE: Inconsistent Yes/No In Access DB

    Are you 110% sure that Main.asp is passing the identifier correctly?<BR><BR>For starters I&#039;d reduce the number of requests by stuffing it once into a variable (instead of doing it atleast twice, each request is processing overhead).<BR>Ie: variable = Request("npid")<BR><BR>And then do all calculations on &#039;Variable&#039;.<BR><BR>Secondly, unless you are passing information to this page through a form AND a querystring, I&#039;d be a little more specific:<BR><BR>Variable = Request.Form("npid")<BR><BR>Then I&#039;d immediately response.write it to the page to verify that it is, indeed, coming through as expected.<BR><BR>You may find that from your main.asp this value is not being passed, or it is being passed not entirely as expected.

  3. #3
    alphadog Guest

    Default RE: Inconsistent Yes/No In Access DB

    Thanks for the reply.<BR><BR>Well, you are right in that the only value I want is NPID, and for testing purposes, the line: <BR><BR>Response.Write "first sql: " & sql<BR><BR>is there for debugging to make me see that I am querying the right record before I issue the opposite Update. It works fine. I am always fetching the right record. The bizarre part is evidenced by the second "debug printout":<BR><BR>Response.Write "Validated: " & rst("Validated")<BR><BR>Now, this is the one that is wrong sometimes. It seems as if the recordset returns the *opposite value* under specific circumstances. I fail to see *how* or *why* it would? A bug perhaps? The ironic thing is that if I refresh this page in the browser, thus running the ASP twice, it then works the second time around.<BR><BR>Thanks for the suggestion and your time, though.

  4. #4
    Join Date
    Dec 1969

    Default More than one record?

    Maybe your SELECT returns more than one record, and which one you see is random?<BR><BR>I&#039;d put in a <BR><BR>Do Until rst.EOF<BR>&nbsp; &nbsp; Response.Write "Validated? " & rst("Validated") & "&lt;BR&#062;"<BR>&nbsp; &nbps; rst.MoveNext<BR>Loop<BR><BR>just as a double check?<BR><BR>

Posting Permissions

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