Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 5th, 2007, 08:12 PM
Registered User
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Variable Problems

Hey All,

I was wondering if someone could try and help me out, i have been at my wits end the last few days trying to get this to work and it just keeps returning mismatch errors.

Basically what i want to do is construct a IF ELSE statement with values that i have dynamically grabbed from a database and also values that are hard coded into the script, below is the code:

Code:
CheckSub1="Chris Rates for 12 months"
CheckSub2="Bob Rates for 6 months"

Dim ssGetRows
Dim S, O

Set ssGetRows = Server.CreateObject("ADODB.Recordset")
ssGetRows.Open "rates", dbGlobal

If ssGetRows.BOF and ssGetRows.EOF Then
  S = " Then"
Else
  ssGetRows.MoveFirst
  While Not ssGetRows.EOF
    S = " cItem.Description = " & ssGetRows("name") & " rates for 6 months OR cItem.Description = " & ssGetRows("name") & " rates for 12 months "
    ssGetRows.MoveNext
      If ssGetRows.EOF then
      Else
      O = "OR"
      End If
    S = S & O
  wEnd
End If

if cItem.Description = CheckSub1 OR cItem = CheckSub2 OR S then
  'Do something
else
  'Do something else
end if
When i do run this, i get a

Type Mismatch: '[string: " cItem.Descripti"]'

on the line that has the if statement.

Please someone help me, i just cant seem to get it going, im desperate.

Thanks

 
Old September 5th, 2007, 09:01 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Apparently cItem is an object of some sort?? In any event it is not declared in the above code snippet. You can convert both objects to a string however which should remove the error, also are you trying to treat S as a bool value?

This line of code will cause your if to bomb: OR S then you arent evaluating S to anything.

This if statement should correct the error:
if (CStr(cItem.Description) = CStr(CheckSub1)) OR (CStr(cItem) = CStr(CheckSub2))


hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
 
Old September 5th, 2007, 09:17 PM
Registered User
 
Join Date: Sep 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks for your response.

I have used S to hold the value of the data coming out of the database, and then add that data into the if statement at the bottom






Similar Threads
Thread Thread Starter Forum Replies Last Post
C variable in WHERE clause problems turnbui MySQL 1 December 7th, 2006 12:55 PM
Session variable problems fogofogo PHP How-To 3 December 28th, 2005 09:42 AM
xslt variable problems lincsimp XSLT 2 August 17th, 2005 02:49 AM
Variable Problems WIx Beginning PHP 1 July 15th, 2004 10:45 AM
Problems displaying images via a variable nancy Classic ASP Basics 2 June 2nd, 2004 02:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.