+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
Web Development Thread, asp server side validation in Coding and Web Development; Ive got a web form to enter codes, which updates a table in a database. The field it's updating is ...
  1. #1

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200

    asp server side validation

    Ive got a web form to enter codes, which updates a table in a database. The field it's updating is linked to another table, which has a table of all the codes, and therefore the code being entered has to exist in the table of codes.

    If I enter in the form a code that doesnt exist in the other table, I get this message, which is understandable.

    Code:
    [Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'codes'.
    How would I go about making sure that what is entered in the form is a valid code in the code table?

    Would I do another query on the update page, and then compare the data from the form to the recordset from the new query or something like that?

  2. #2

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    How many codes are there?

    Could you populate a dropdown with all the valid codes to avoid the problem?

  3. Thanks to CESIL from:

    RabbieBurns (3rd February 2009)

  4. #3

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    Or you could execute a query to return any matching records from the code table against the code from the form.

    If any records are returned (it should be just 1 I guess) then the code is valid.

  5. #4
    ICTNUT's Avatar
    Join Date
    Jul 2005
    Location
    Hereford
    Posts
    1,419
    Thank Post
    196
    Thanked 249 Times in 122 Posts
    Rep Power
    62
    I agree with cadjs, is there any reason why you cannot create adrop downlist with the codes pre populated.

    This would avoid the requirement for validation completly.

    If you need code forthe dropdown let me know

  6. Thanks to ICTNUT from:

    RabbieBurns (4th February 2009)

  7. #5

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    hmm, thats an idea actually..

    however, its basically a form for changing the set a student is in, and theres 38 set codes, but only 2-4 sets per subject.

    So I thought for them to just change "4MATH 4" to "4MATH 3"
    by just changing the last digit, it might be easier.



    I will have a dabble with the dropdown, thanks for the idea

  8. #6

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    you should be able to filter the codes in the dropdown by using the subject.

    That way they will only see valid codes for the subject involved.

  9. #7

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Quote Originally Posted by ICTNUT View Post
    I agree with cadjs, is there any reason why you cannot create adrop downlist with the codes pre populated.

    This would avoid the requirement for validation completly.

    If you need code forthe dropdown let me know
    Ive changed them to dropdowns, however my code only seems to populate the first entry with all of the available codes, then not the rest.

    Ive obvioulsy messed up a loop somewhere..

    Can you spot my mistake?

    edugeek private pastebin - collaborative debugging tool

  10. #8

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Quote Originally Posted by cadjs View Post
    you should be able to filter the codes in the dropdown by using the subject.

    That way they will only see valid codes for the subject involved.
    Sounds ideal.. could you show or point me in the direction to learn about filtering please, its not something I know about yet.

  11. #9

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    you need to reset the record pointer to the first record in your recordset once the first loop is done

  12. Thanks to CESIL from:

    RabbieBurns (3rd February 2009)

  13. #10

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    to filter the codes you could either do a query per subject or use the subject to determine each subject as you loop through the recordset. As long as the codes are sorted by subject you would know that all the maths ones are together etc.

  14. #11

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Sorted, thanks.

    Now, to be able to filter the sets per subject would be the icing on the cake

    edit:

    to filter the codes you could either do a query per subject or use the subject to determine each subject as you loop through the recordset. As long as the codes are sorted by subject you would know that all the maths ones are together etc.
    I cant think in my head how that would work, the codes are sorted alphabetically, as are the subjects, but different subjects have different amounts of codes etc
    Last edited by RabbieBurns; 3rd February 2009 at 03:15 PM.

  15. #12

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    BTW I think your counter 'bug' is caused by staring the counter at 1 rather than 0...

  16. #13

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Quote Originally Posted by cadjs View Post
    BTW I think your counter 'bug' is caused by staring the counter at 1 rather than 0...
    If i start it at 0 I get this:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'reportID ='.

    /S4/updatesets.asp, line 36
    which corresponds to the conn.execute line here:

    http://edugeek.pastebin.com/m38b8a3b4
    Last edited by RabbieBurns; 3rd February 2009 at 03:23 PM.

  17. #14

    RabbieBurns's Avatar
    Join Date
    Apr 2008
    Location
    Sydney
    Posts
    5,527
    Thank Post
    1,339
    Thanked 470 Times in 307 Posts
    Blog Entries
    6
    Rep Power
    200
    Actually, thinking about it, I am just going to leave the dropdown as it is.

    Often here students change their subjects from say maths to Art instead for example. This way itll let me change the whole subject by just changing the set.

  18. #15

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,404
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    there is a counter in the update page that starts at 1...this should probably start at 0 as well...

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. PHP form validation
    By thesk8rjesus in forum Web Development
    Replies: 10
    Last Post: 21st January 2009, 12:09 AM
  2. Allow ASP .Net 2 in IIS Server 2003 R2
    By FN-GM in forum Windows
    Replies: 8
    Last Post: 17th January 2009, 08:23 PM
  3. windows validation
    By strawberry in forum Windows
    Replies: 2
    Last Post: 7th May 2008, 05:24 PM
  4. Server Core 2008 - missing ASP
    By pete in forum Windows Server 2008
    Replies: 4
    Last Post: 28th February 2008, 06:09 PM
  5. 100% server side software
    By starscream in forum Windows
    Replies: 9
    Last Post: 6th June 2007, 10:09 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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