Testing RS.Fields("myfield")

Results 1 to 3 of 3

Thread: Testing RS.Fields("myfield")

  1. #1
    Join Date
    Dec 1969

    Default Testing RS.Fields("myfield")

    Lets say I have connected to an access database and are about to assign values from a form to the RS.Fields collection. For very large forms it is easy to loose a field name, I.E. not have a corresponding field in the database or RS.Fields collection so when I try to make RS.Fields("myfield") = Request.Form("myfield") I could bomb out with an error like not in collection. Can I test the field I want to assign a value to before with something like If RS.Fields("myfield") exists and Request.Form("myfield") &#060;&#062; "" Then<BR>RS.Fields("myfield") = Request.Form("myfield")<BR>Can someone tell me the functions I need to use ?<BR>thanks<BR>Milton

  2. #2
    Join Date
    Dec 1969

    Default Pardon me, but...

    ...this is silly.<BR><BR>You *WANT* to get that error, the first time you try to use the page. So that you will then fix the code so it doesn&#039;t happen again.<BR><BR>And then you run back to Access, look at the list of fields, change your code, and you are in business.<BR><BR>Or you can list all the fields, by name, easily enough in ASP code. Check the ASPFAQs to see how.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: you can see the name-value

    pairs of your formdata before you post your page.<BR><BR>The following code loops through the form elements and prints all of them in name-value pairs. Then you can compare the names here with your table in the database and see what is going and what is not.<BR><BR>dim itm<BR>for each itm in request.form<BR>response.write itm & "=" & request.form(itm) & "<BR>"<BR>next<BR>response.end

Posting Permissions

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