Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 29th, 2004, 11:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default 'expected then' VB script compilation error

Hi there

I'm getting a compilation error and I'm not sure why. Here's the rogue code:

intTotalPrice = intTotalPrice + (intQuantity * intPrice)

Set rsPacking = server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM PPack ORDER BY PPid DESC"

set rsPacking = con.execute(strSQL)

if rsPacking.EOF then

else

do while not rsPacking.EOF

intPP = 0

If intTotalPrice > rsPacking("Limit") where rsPacking("PPid") = 1 then
intPP = rsPacking("FixPrice")
elseif intTotalPrice rsPacking("Limit") where rsPacking("PPid") = 2 then
intPP = rsPacking("FixPrice")
else
intPP = rsPacking("FixPrice") where rsPacking("PPid") = 3
end if
rsPacking.movenext()
loop
end if


The error is on line:

If intTotalPrice > rsPacking("Limit") where rsPacking("PPid") = 1 then


The error reads: Microsoft VBScript compilation error '800a03f9'

Expected 'Then'

Not sure how to get out of it?

Any help much appreciated.

thanks

Adam
Reply With Quote
  #2 (permalink)  
Old January 29th, 2004, 03:54 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,409
Thanks: 0
Thanked 16 Times in 16 Posts
Default

"where" is not a VBScript keyword. It looks like you are trying to mix SQL into VBScript. What are you trying to do with that set of If/ElseIf?

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #3 (permalink)  
Old January 30th, 2004, 04:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Hi Peter,

thanks for your input.

What I'm trying to achieve is a set of conditions where if the total amount of the shopping basket is over 50 then postage and packing is 5; if the total amount of the shopping basket is between 30-50, then postage and packing is 3 and if the total amount of the shopping basket is less 20, then the postage and packing will cost 2.

All values are being read from a SQL db. It seems that I'm not doing it correctly. Do you know how I can remedy it?

many thanks

Adam
Reply With Quote
  #4 (permalink)  
Old January 30th, 2004, 01:26 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,409
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Where do you want to do this test? You could do it either in SQL or in VBScript. What do you mean by this: where rsPacking("PPid") = 1
Is this some postage and packing ID that corresponds to the limits?

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old January 30th, 2004, 01:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Hi Peter

Yes, that's right it corresponds to the incremental auto number that sql creates.

I want it so that an administrator can change the values when he or she so desires, so I need it to be database driven really. How would I be able to do this in SQL?

thanks

Adam
Reply With Quote
  #6 (permalink)  
Old January 30th, 2004, 01:43 PM
Authorized User
 
Join Date: Dec 2003
Location: Middletown, CT, USA.
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Substitute and for where...from a syntax point that is what you are trying to acheive...however, that may not logically cover all your scenarios


As for the logic, you may want to consider a select case statment
that looks at the three values of ppid and runs a series of commands accordingly. This will probably be easier than SQL


John
Reply With Quote
  #7 (permalink)  
Old January 30th, 2004, 01:58 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,409
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok, I think I get what you are doing. You need to select the shipping cost in a tiered cost system. Perhaps this will work...

strSQL = "SELECT MIN(FixPrice) WHERE Limit > " & intTotalPrice

This will give you the minimum fixed shipping cost of all the costs that correspond to limits that are larger than your total.
Reply With Quote
  #8 (permalink)  
Old January 30th, 2004, 02:00 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,409
Thanks: 0
Thanked 16 Times in 16 Posts
Default

And BTW, you only need to select a single row value for this.
No need to loop thru rows.

Plus the benefit of this is that you can add tiers to the database without changing the logic of it.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #9 (permalink)  
Old January 31st, 2004, 04:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Great, thanks for your input guys - I'll give what you said a shot.

Cheers

Adam
Reply With Quote
  #10 (permalink)  
Old July 19th, 2009, 11:02 AM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error: Expected'Then' Code : 800A03F9

Hi ,

I am getting error while compling the vb script

Error: Expected'Then'
Code : 800A03F9

I am running follwoing vb script for renaming a file.

DIM sourcepath
sourcepath="D:\NEW" 'The path to the source file, includes backslash
DIM sourcefile
sourcefile="server.log" 'The name of the source file without a loop number
DIM destpath
destpath="D:\NEW" 'The path to the destination file, includes backslash
DIM max
max=1000 'The maximum number of copies to keep
DIM a
a=0 'A loop counter
'**** Main Loop ****
FOR a = max-1 TO 1 'Create a decreasing loop counter
IF EXIST destpath$ & sourcefile$ & a THEN 'If the filename with current counter's value exists.....

COPY (sourcepath$ & sourcefile$, destpath$ & sourcefile$ & a+1) 'Copy the file adding the loop counter + 1

END NEXT 'Break out of the FOR-NEXT loop now
END IF
NEXT a 'Otherwise, decrement the loop counter by one and try again.


If someone can help ,

Thanks in Advance
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
type mismatch error in VB Script spierson99 SQL Server DTS 2 February 20th, 2006 11:13 AM
VBScript compilation (0x800A0400) Expected stateme Tom_Nguyen Classic ASP Basics 3 January 2nd, 2006 06:53 PM
Error: Function expected lameneural Java Basics 0 December 1st, 2005 05:57 AM
asp vb script error rsjaladi Classic ASP Databases 2 November 26th, 2004 09:46 AM
DTS & VB script error kpowers@wppisys.org SQL Server DTS 1 June 5th, 2003 04:34 PM



All times are GMT -4. The time now is 08:37 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.