Session Variables & Fields in a Table

Results 1 to 6 of 6

Thread: Session Variables & Fields in a Table

  1. #1
    Feuer Guest

    Default Session Variables & Fields in a Table

    Greetings. I had a post yesterday that got into using session variables to store form element data. I got to the point where I was trying to writing these values to a table where the field names identically matched the variable names.<BR><BR>To get the name/value into session variables, I used this:<BR>For Each Item In Request.Form<BR> Session(Item) = Request.Form(Item)<BR>Next<BR><BR>To get them into my table I am using this:<BR>Set Connect = Server.CreateObject("ADODB.Connection")<BR>Connect .Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath("quotes.mdb")<BR>Set RS =Server.CreateObject("ADODB.Recordset")<BR>sql = "SELECT * FROM quotes"<BR>RS.Open sql, Connect, 1, 3 <BR>RS.AddNew<BR>For Each Key In Session.Contents<BR> RS(Session(Key)) = Session.Contents(Key) <BR>Next <BR>RS.Update<BR>RS.Close<BR>Set RS = Nothing<BR><BR>Five lines up, look at the left side where it says RS(Session(Key)). I get an error message that says "Item cannot be found in the collection corresponding to the requested name or ordinal." I hard-coded a field name in place of RS(Session(Key)) and got in. I changed it back and got the error. <BR><BR>Could the syntax for identifying the field name to match up with be wrong? I keep trying little variations of this but am not getting anywhere: RS(Session(Key))<BR><BR>Thanks to all.

  2. #2
    Steve Cimino Guest

    Default RE: Session Variables & Fields in a Table

    Possibly.<BR><BR>You should response.write out everything in your loop to see what the data is actually containing. Response.write the value of KEY, and if that&#039s fine, response.write out the values of your sessions then.

  3. #3
    Feuer Guest

    Default RE: Session Variables & Fields in a Table

    That&#039s exactly what I did when I first encountered the problem. I took inventory and can confirm that the spelling of each variable is identical to the fields in the table. There are also no fields missing from the table that are in the session object. What now? : (

  4. #4
    Steve Cimino Guest

    Default RE: Session Variables & Fields in a Table

    What does it contain? It seems to choke on the session item, not the db item, according to your error message. Is all your code on the same page? If not, do you have cookies enabled?<BR><BR>Can you paste the response.write of the session names and the contents here?

  5. #5
    Feuer Guest

    Default RE: Session Variables & Fields in a Table

    It&#039s lengthy, but here are the values stored in the session variables. I left the values blank for the most part. It takes a long time to fill out the form. The values aren&#039t the problem anyway. Where you do see a value, it&#039s because it was a selected value in a drop-down. Again, I want to point out that every name you see here is indeed in the Access table and is spelled correctly (I&#039ve combed through it three times now). Yes, cookies are enabled on my machine. The reason I am using the session object is because I am passing data through 3 pages to get to this point. There are many text fields involved, so I wanted to avoid potential encoding problems by avoiding the use of hidden form fields.<BR><BR>bpumpquan<BR>fumedetdesc<BR>radarde sc<BR>rdfquan<BR>op1st<BR>op2sex<BR>op3dob<BR>usps c2date<BR>pbol5<BR>waterskidesc<BR>paidcrewdesc<BR >declineddesc<BR>bpumpdesc<BR>rdfdesc<BR>op2ssn<BR >op3st<BR>op4sex<BR>op5dob<BR>pbol2<BR>uscgc5date< BR>licensedesc<BR>surveydate<BR>stovequan<BR>radar quan<BR>op1dob<BR>uscgc4date<BR>insurancedesc<BR>b inderexp<BR>stovedesc<BR>fumedetquan<BR>atdquan<BR >op1name<BR>op1dln<BR>op1yrs<BR>op4ssn<BR>op5st<BR >uspsc3date<BR>racingdesc<BR>arsondesc<BR>co2quan< BR>s2sradioquan<BR>s2sradiodesc<BR>op5name<BR>op5m stat<BR>op5dln<BR>op5yrs<BR>uscgc1date<BR>uspsc4da te<BR>pbol4<BR>businessdesc<BR>accidentdesc<BR>co2 desc<BR>firequan<BR>firedesc<BR>atddesc<BR>op1sex< BR>op2dob<BR>pbol1<BR>lossesdesc<BR>depthquan<BR>o p1ssn<BR>op2st<BR>op3sex<BR>op4dob<BR>uscgc2date<B R>uspsc5date<BR>depthdesc<BR>equipotherquan<BR>equ ipotherdesc<BR>op1mstat<BR>op4name<BR>op4dln<BR>op 4yrs<BR>uspsc1date<BR>sleepingdesc<BR>bindereff<BR >heatingquan<BR>op2name<BR>op2dln<BR>op2yrs<BR>op4 mstat<BR>op5ssn<BR>uscgc3date<BR>pbol3<BR>impairde sc<BR>heatingdesc<BR>op2mstat<BR>op3name<BR>op3mst at<BR>op3dln<BR>op3yrs<BR>chartereddesc<BR>curradd rdesc<BR>bindertime<BR>op3ssn<BR>op4st<BR>op5sex<B R>routeyacht<BR>city<BR>tother<BR>bterritory<BR>qu otedate<BR>coplan<BR>st<BR>bpurch<BR>bregnum<BR>bl ayup212<BR>name1<BR>polnum<BR>name2<BR>power-other-desc<BR>bmanufac<BR>bmodel<BR>bname<BR>addr1<BR>ef date<BR>bspeed<BR>bvalue<BR>blayup11<BR>zip<BR>acc t<BR>addr2<BR>dother<BR>phone<BR>bhullid<BR>exdate <BR>bnavlakesrivers<BR>bloc<BR>byear<BR>blength<BR >bnew<BR>bzip<BR>eom1year<BR>trcap<BR>om1limit<BR> skilimit<BR>credits<BR>ai1state<BR>ai2city<BR>eom1 mm<BR>eom1value<BR>eom3year<BR>hded1<BR>pebded<BR> coverages<BR>ai1city<BR>eom1snum<BR>eom1hp<BR>eom1 other<BR>eom2purch<BR>om2ded<BR>trded<BR>towlimit< BR>ai1zip<BR>eom1purch<BR>om3limit<BR>ai2addr<BR>e om1cost<BR>eom2mm<BR>eom2value<BR>hlimit50000-100000<BR>unboatlimit5000<BR>trlimit<BR>skiingincl uded<BR>credlimit<BR>eom2year<BR>trpurch<BR>liabli mit100000<BR>pesded<BR>towded<BR>peblimit2500<BR>e om2snum<BR>eom2hp<BR>eom2other<BR>eom3purch<BR>mpa ylimit2500<BR>ai1addr<BR>ai2state<BR>eom2cost<BR>e om3mm<BR>eom3value<BR>peslimit<BR>ai2name<BR>ai2lo an<BR>eom3snum<BR>eom3hp<BR>eom3other<BR>tryear<BR >trmm<BR>om1ded<BR>eom3cost<BR>traxle<BR>om2limit< BR>totalprem<BR>trsnum<BR>trcost<BR>om3ded<BR>ai1n ame<BR>ai1loan<BR>ai2zip<BR><BR>One more note: I have also tried using response.write during the for/next loop to see which field name it&#039s getting hung up on, but the error comes up immediately. I don&#039t get to see any progress. I have even changed the order that variables are assigned to the session object to verify that the first field wasn&#039t a problem. It seems to be the whole darn thing.<BR>

  6. #6
    Join Date
    Dec 1969

    Default RE: Session Variables & Fields in a Table

    The fifth line from bottom should be:<BR><BR>RS(Key) = Session.Contents(Key) <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