Becoming frustrated..need help

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Becoming frustrated..need help

  1. #1

    Default Becoming frustrated..need help

    Guys, I have this really annoying problem. Im carrying out a basic insertion to an Access db using the addnew method.<BR><BR>Heres the code...<BR><BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR>objRS.Op en "members", Calconn, adLockOptimistic, adCmdTable<BR> <BR>objRS.AddNew<BR>objRS("member_firstname") = session("first_name")<BR>objRS("member_lastname") = session("last_name")<BR>objRS("member_username") = session("user_name")<BR>objRS("member_password") = session("password")<BR>objRS("member_email") = session("email")<BR>objRS("member_address") = session("address")<BR>objRS("member_state") = session("state")<BR>objRS("member_suburb") = session("suburb")<BR>objRS("member_city") = session("city")<BR>objRS("member_postcode") = session("postcode")<BR>objRS.Update<BR> <BR>session.Contents.Remove("first_name")<BR>sessi on.Contents.Remove("last_name")<BR>session.Content s.Remove("user_name")<BR>session.Contents.Remove(" password")<BR>session.Contents.Remove("email")<BR> session.Contents.Remove("address")<BR>session.Cont ents.Remove("state")<BR>session.Contents.Remove("s uburb")<BR>session.Contents.Remove("city")<BR>sess ion.Contents.Remove("postcode")<BR><BR><BR>For some really odd reason, the first insertion is carried out with no problem, however after that my session variables become screwed and it only inserts the first value. By this I mean, when you use the form the first time its fine. Then if you try and add another record it falls over. I thought it should either work or not at all. When it falls over only the firstname is added and the rest of the record has null values.<BR><BR>Heres the submit button that pushes to the insertion page. I cant see anything wrong here at all???<BR><BR>&#060;input type=submit value="Process Request" name="process" onclick="this.form.submit() ;this.form.action=&#039;../includes/process_members.asp?action=addmember&#039;" class="textbox"&#062;<BR><BR>Im at an end here. Ive tried troubleshooting my code, minimising it right down to absolute basics, but Im still getting this problem. What to do?????<BR><BR>Thanks,<BR>John

  2. #2
    Join Date
    Dec 1969

    Default So where do the session values...

    ...come from???<BR><BR>After you do the UPDATE, you seem to be removing *all* the relevant values, so the culprit would appear to be whatever is putting the next set of values into the session variables.<BR><BR>Have you DEBUGGED???<BR><BR>In particular, have you done something like<BR> For Each nm In Session.Contents<BR> Response.Write "Session(" & nm & ") = " & Session(nm) & "&#060;br/&#062;"<BR> Next<BR> Response.Write "&#060;HR&#062;"<BR>into various places in your pages?<BR><BR>I&#039;m a little curious as to why you are even USING session variables, given that you SEEM to be submitting the info via a &#060;FORM&#062;. But you show way too little code for me to guess.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default I see one big screwup... *FIRST* submit the form using this.form.submit() and *THEN* you change the action= of the form!!! TOO LATE! The submit is done and nothing after that is going to take place.<BR><BR>I don&#039;t even understand why you are CALLING this.form.submit()!<BR><BR>It *IS* a submit button, so if you simply return true from the onClick it will automatically submit the form.<BR><BR>&#060;input type=submit value="Process Request" name="process" class="textbox"<BR> onclick="this.form.action=&#039;../includes/process_members.asp?action=addmember&#039;; return true;"&#062;

  4. #4

    Default Okay Bill...

    Bill,<BR>The first page is just a basic form, which passes to the confirmation page. Here, the entries are validated and passed to session variables. <BR><BR>So the initial form contains...<BR><BR>&#060;input type="text" name="member_lastname" class="textbox" maxlength=30 size="22"&#062;<BR><BR>And the confirmation page contains...<BR><BR>&#039;ENSURE A VALID LASTNAME<BR>if request.form("last_name") = "" then<BR>continue = "FALSE" (this controls the process of the page)<BR>response.write "ERROR, BLAH BLAH BLAH..."<BR>else<BR>session("last_name") = request.form("last_name")<BR>end If<BR><BR>Yes I have debugged, and from what I can see I successfully create all of the session variables as intended on the confirmation page. Its when I press the submit button from the confirmation page to the actual insertion page, they somehow are lost???<BR><BR>I cannot for the life of me see where.<BR><BR>John

  5. #5

    Default whats weird here Bill is that

    It works occasionally...not always but sometimes...<BR><BR>Something really odd is going on. Ive pulled this code apart repeatadly....AAAGGGHH!!!<BR><BR>Ive fixed up the button, but that hasnt changed anything.<BR><BR>Ill keep going...<BR><BR>John

  6. #6
    Join Date
    Dec 1969

    Default Well, you've got me...

    If you&#039;d said that *all* the session variables were disappearing, I&#039;d be looking for a Session.Abandon or maybe cross virtual directory scripting, but if some of them are still okay... Really, I have no idea.<BR><BR>Have you considered using hidden form fields on the confirmation page, instead of session variables?<BR><BR>&#039;ENSURE A VALID LASTNAME<BR>lname = request.form("last_name") <BR>If lname = "" then<BR> continue = False &#039; should use a boolean, not a string?<BR> response.write "ERROR, BLAH BLAH BLAH..."<BR>else<BR>%&#062;<BR> &#060;INPUT TYPE=HIDDEN Name="last_name" Value="&#060;%=lname%&#062;" &#062;<BR>&#060;%<BR>end If<BR><BR>... next field similar ...<BR>%&#062;<BR><BR>But, honestly, I can&#039;t see why session var&#039;s wouldn&#039;t work.<BR><BR>

  7. #7

    Default okay....update

    What I just did was completely RENAME every form feild and session value to that of something else.<BR><BR>Believe it or not, it now appears to be working. I know what youre thinking Bill...<BR><BR>"Bloody idiot had the wrong field names or his request objects werent spelt right or something..."<BR><BR>BUT I SWEAR TO YOU! that I checked and RECHECKED this over and over and over....<BR><BR>What wouldve caused this????????<BR><BR>John

  8. #8
    Join Date
    Dec 1969

    Default hash table collision???

    Session variables (and, indeed form fields in Request.Form) are stored in a hash table. And it *is* possible that two keys could "hash" to the same value.<BR><BR>[ Session("one") and Session("two") use the keys "one" and "two"...similarly for Request("one") and Request("two") ]<BR><BR>Now, any decent hash table *does* have rules on how to resolve such collisions (they use "hash buckets" and extend the buckets and and and), but JUST POSSIBLY you found one collision that wasn&#039;t being handled correctly???<BR><BR>It&#039;s a one in a million chance, but that&#039;s not the same as zero, is it?<BR><BR>

  9. #9

    Default Bill, just a few questions...

    1. Could you explain further on this. "cross virtual directory scripting"<BR><BR>Also, on this...<BR><BR>Have you considered using hidden form fields on the confirmation page, instead of session variables?<BR><BR>&#039;ENSURE A VALID LASTNAME<BR>lname = request.form("last_name") <BR>If lname = "" then<BR>continue = False &#039; should use a boolean, not a string?<BR>response.write "ERROR, BLAH BLAH BLAH..."<BR>else<BR>%&#062;<BR>&#060;INPUT TYPE=HIDDEN Name="last_name" Value="&#060;%=lname%&#062;" &#062;<BR>&#060;%<BR>end If<BR><BR><BR>I would much prefer to use hidden form fields as the overheads on using them are lower in terms of memory resources on the server. Is that correct?<BR><BR>And is this method possible on a multi step page....? By this I mean a form that contains steps 1, 2, 3 etc<BR><BR>Thanks Bill,<BR>I owe you a cappacino!<BR><BR>John

  10. #10

    Default Hmmm interesting point actually

    Because I was running this same method to ensure valid password entries...<BR><BR>In that I mean, ensure both passwords<BR><BR>a)match<BR>b)are of a valid length<BR>c)are not blank<BR><BR>I just checked over my code and interestingly enough I had values assigned on different request objects<BR><BR>NOT BLANK<BR>session("password") = request.form("password12")<BR><BR>AT LEAST 5 CHARACTERS<BR>session("password") = request.form("password1")<BR><BR>MATCHING<BR>sessi on("password") = request.form("password1")<BR><BR>Something like that anyhow....maybe this was causing the problem. I guess it could have been. Ive set them all to request.form("password2")<BR><BR>John

Posting Permissions

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