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 ...
-
3rd February 2009, 01:58 PM #1 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?
-
-
IDG Tech News
-
3rd February 2009, 02:10 PM #2 How many codes are there?
Could you populate a dropdown with all the valid codes to avoid the problem?
-
Thanks to CESIL from:
RabbieBurns (3rd February 2009)
-
3rd February 2009, 02:19 PM #3 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.
-
-
3rd February 2009, 02:20 PM #4 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
-
Thanks to ICTNUT from:
RabbieBurns (4th February 2009)
-
3rd February 2009, 02:37 PM #5 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
-
-
3rd February 2009, 02:57 PM #6 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.
-
-
3rd February 2009, 03:04 PM #7 
Originally Posted by
ICTNUT
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
-
-
3rd February 2009, 03:05 PM #8 
Originally Posted by
cadjs
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.
-
-
3rd February 2009, 03:08 PM #9 you need to reset the record pointer to the first record in your recordset once the first loop is done
-
Thanks to CESIL from:
RabbieBurns (3rd February 2009)
-
3rd February 2009, 03:11 PM #10 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.
-
-
3rd February 2009, 03:12 PM #11 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.
-
-
3rd February 2009, 03:14 PM #12 BTW I think your counter 'bug' is caused by staring the counter at 1 rather than 0...
-
-
3rd February 2009, 03:20 PM #13 
Originally Posted by
cadjs
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.
-
-
3rd February 2009, 03:30 PM #14 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.
-
-
4th February 2009, 09:57 AM #15 there is a counter in the update page that starts at 1...this should probably start at 0 as well...
-
SHARE: 
Similar Threads
-
By thesk8rjesus in forum Web Development
Replies: 10
Last Post: 21st January 2009, 12:09 AM
-
By FN-GM in forum Windows
Replies: 8
Last Post: 17th January 2009, 08:23 PM
-
By strawberry in forum Windows
Replies: 2
Last Post: 7th May 2008, 05:24 PM
-
By pete in forum Windows Server 2008
Replies: 4
Last Post: 28th February 2008, 06:09 PM
-
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
-
Forum Rules