navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Update Multiple Records

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Update Multiple Records
Page: [1]
 
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

Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Update Multiple Records - 3/31/2003 16:39:37   
You may want to set myDate=now() ? or is the timestamp different?

With each checkbox, they are all NAMEd " myCheckbox" ?
When using IN, the value will be the record ID from each selected check box.
So, each checkbox named " myCheckbox" will nedd a VALUE of that records ID.

Check out the Spooky diet in my sig failing that, and we can then " response.write" the SQL string to see where the error lays.

NOTE - you cant do " myCheckbox=::myCheckbox:: "
The result of myCheckbox will more than likely be a comma delimited string.
Is there reason to update this column?

< Message edited by Spooky -- 3/31/2003 4:41 PM >


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Pete007hall)
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 :)

(in reply to Pete007hall)
Spooky

 

Posts: 26599
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Update Multiple Records - 4/1/2003 19:05:10   
Although the checkboxes are generated automatically, the names arent.

NAME the check box " myUpdateBox" for example, and then for the value, use : <%=FP_FIELD(fp_rs," ID" )%> where ID is the record ID column name.
This will give all of the checkboxes the " VALUE" you need for further processing.
The entire DRW would need to be contained within the 1 form area, so that all results are submitted at the same time.

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to Pete007hall)
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!!???

:)

(in reply to Pete007hall)
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.

(in reply to Pete007hall)
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!!

:)

(in reply to Pete007hall)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Update Multiple Records
Page: [1]
Jump to: 1





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