Executing a loop containing a query via script

A

Alan

Dear Frontpage guru

My form has two date fields and I need to append a MSAccess table with a row
for each day between the two dates. Using VBScript driven from the submit
button I can calculate the contents of each row I wish to append but I do
not know how to then run the append query as such.

while tmpdate<EndDate

The following line and the execution of the query is the bit I don't
know how to do
fp_sQry="insert into tblBookingList (BookingDetailID, date)
values(intBookingDetailID,tmpDate)"

I then increment tmpDate and cycle throught the loop again
tmpDate = dateadd ("d",1,tmpDate)
wend

Can anyone help please.

Thanks...Alan
 
S

Stefan B Rusynko

See http://www.codefixer.com/tutorials/insert_into_database.asp

Note:
Trust you are aware your process will
- create duplicate records unless BookingDetailID is always unique for each use (and may fail if you have any Access fields set as
indexed - unique) ,
- and if the date range is very large may create a massive DB

--




| Dear Frontpage guru
|
| My form has two date fields and I need to append a MSAccess table with a row
| for each day between the two dates. Using VBScript driven from the submit
| button I can calculate the contents of each row I wish to append but I do
| not know how to then run the append query as such.
|
| while tmpdate<EndDate
|
| The following line and the execution of the query is the bit I don't
| know how to do
| fp_sQry="insert into tblBookingList (BookingDetailID, date)
| values(intBookingDetailID,tmpDate)"
|
| I then increment tmpDate and cycle throught the loop again
| tmpDate = dateadd ("d",1,tmpDate)
| wend
|
| Can anyone help please.
|
| Thanks...Alan
|
|
 
A

Alan

Thanks Stefan
Yes I was aware of the issues you raised and had tried to use VB code
similar to hte one shown in your link.
I have now got it working but am unsure what is different.
I did notice that when I wrote the VB code in Frontpage, published it and
then looked at it on Internet Explorer I got a different result (ie it
worked versus didn't work) if I initially just refreshed the asp page,
rather than call it up from a hyperlink from the index.html file.
Presumably refreshing does not call up the underlying code from the server.
Anyway it is now working and I thank you for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top