|
| |
|
|
Pete007hall
Posts: 4 Joined: 3/10/2003 Status: offline
|
Update Multiple Records - 3/31/2003 10:20:49
Hi, Im trying to update multiple records in a database at the same time.. I have the DRW output some of the records from an access database to an .asp page, and each record has a checkbox next to it, automatically ticked. What i want to be able to do is update the database records with a datestamp (generated by javascript into a textbox called myDate) and also update the checkbox in the database.. but only for the records ticked, which isnt necessarily all of the records in the database.. SQL code im using currently looks like this: UPDATE Results SET myDate=' ::myDate::' , myCheckbox=::myCheckbox:: WHERE COLUMN IN (::myCheckbox::) note: the access database field " myDate" is a text field as Javascript produces a really long date with some UTP rubbish in it!!) Problem is that im getting the old " Too Few Parameters. Expected 1" error and it doesnt want to know.. I can give it default values for the myDate and myCheckbox fields but that doesnt help, and also i dont want it to put in default values, as it should update if the checkbox is ticked and not do anything if its not... Im getting myself really confused with this one, playing with syntax and changing names of the fields etc to try and make it work, but to no avail. Any ideas what im doing wrong?? Thanks Peter
|
|
|
|
Pete007hall
Posts: 4 Joined: 3/10/2003 Status: offline
|
RE: Update Multiple Records - 4/1/2003 5:18:32
Hi, thanks for getting back to me... The javascript im using is to populate a text box with the current date\time when the page is loaded, and produces a string similar to " Tue Apr 1 10:45:15 UTC+0100 2003" This is then submitted with the form as myDate. I want this to be updated in the database as the time when those records ticked are ticked. The form only has one date field which needs to be updated in each record ticked. Script used to create this date is: var now = new Date(); fixDate(now); function fixDate(date) { var base = new Date(0); var skew = base.getTime(); if (skew > 0) date.setTime(date.getTime() - skew); } Then i update the value of the form textbox with the value " now" The checkboxes are a little more complicated for me, as when i produce the page there is only one checkbox... It is part of the database results wizard and so its only when the page is run that there more than one of them... I have called the one i can see " SentRecall" (" myCheckbox" sounded easier to explain first time). It is a tickbox to say that the records have been emailed to another person, using CDONTS code in the submit .asp page. When the page is loaded the database results wizard will ignore the records with the database checkbox ticked and a date in the database field. So, when the page loads the user gets a list of records that have not been sent by email, they tick the boxes required and submit the form, it then updates the date field in the database and ticks the yes\no field in the database to say they have been sent. Next time the page loads, it ignores those records... (Hope that makes sense?) I have a database field (text) for the date, format as above, and a database yes\no field for the checkbox. I figured im running into problems with the checkboxes.. especially since they are generated automatically and i cant name them individually... Also, the value of the ID field in the database would be different each time the page loads as it would return different records each time. Hope this helps you to understand what im trying to do a bit more.. Its (for me) quite confusing stuff, and maybe im going about it wrong, but hey! thats how im leaning :)
|
|
|
|
Pete007hall
Posts: 4 Joined: 3/10/2003 Status: offline
|
RE: Update Multiple Records - 4/3/2003 9:21:18
Thanks Spooky... I feel i am nearly there now... Still getting a few problems though... let me explain what ive done.. Ive got rid of the need for a checkbox field in the database so all im trying to update is the Date field, for those DRW records that get their box ticked. Because each checkbox in the DRW has a unique value, the same as the record ID in the database, i have now altered the sql as such: UPDATE Results SET SentDate=' ::SentDate::' WHERE ID=(::SentRecall::) (p.s. ive also tried WHERE (::SentRecall::) = ID, as this sounded more appropriate!) where SentDate is the date field in the database and on the form, and SentRecall is the name of the checkbox on the form. ID is the database record ID (autonumber field) And, as a point from your last post, I am using one form to sumbit all the data at the same time. My errors now stem from a comma in the sql statement causing syntax errors.. I cant get it to come out with WHERE ID=1, ID=2 etc.. Im getting ID=(1, 2, 3) I guess its a question of where to place to brackets but i cant seem to get it working no matter where i put them!! What AM i doing wrong!!??? :)
|
|
|
|
rdouglass
Posts: 9187 From: Biddeford, ME USA Status: offline
|
RE: Update Multiple Records - 4/3/2003 10:22:10
quote:
WHERE ID=(::SentRecall::) Have you tried: WHERE ID IN ::SentRecall::
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
Pete007hall
Posts: 4 Joined: 3/10/2003 Status: offline
|
RE: Update Multiple Records - 4/3/2003 10:45:29
Hi, I have tried this, but im getting errors before the query is verified saying: Server error: Unable to retrieve schema information from the query: In operator without () in query expression ' ID IN 2' . Ive tried putting brackets around the ::SentRecall:: and ID bits, and both, and the error chenges to the standard " too few parameters error" Sorry!! :)
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|