Link to home
Start Free TrialLog in
Avatar of davidi1
davidi1Flag for India

asked on

IF.., Then in ASP

Team -

I have a table in sql called "Goals" where i have the following columns & values

Goal - Varchar(255)
GoalTarget - Varchar(255)
PI1Value - Varchar(255)
PI1Symbol - Varchar(255)

Values:
Accuracy
98
97
>

I have another table in sql called "Goalsheet" where the following columns and values are updated.

Goalsheet
Goal - Varchar(255)
GoalAchieved - Varchar(255)

I want to do a If Then statement in asp

If Goalachieved & PI1Symbol & PI1Value Then
PIScore = 1
Else
....
End if

However I'm getting error. "Type mismatch: '[string: "98<97"]' "

Please help..,

any help from sql side also would be great, kindy help.
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

You can use the eval function

<%
GoalTarget = "98"
PI1Value = "97"
PI1Symbol = "<"

' option 1 *************************************

sql=cdbl(GoalTarget) &  trim(PI1Symbol) &    cdbl(PI1Value)
if  eval(sql ) then
	response.write "Its true"
	else
	response.write "it's false"
end if


' option 2  *************************************
response.write "<hr>"
if testit GoalTarget, PI1Value, PI1Symbol = 1 then
	response.write "function true"
	else
	response.write "function false"
end if

' fuction can go anywhere on your page, top bottom or middle.  Best to put them all in one spot or maybe as an include file
function testit(GoalTarget,PI1Value,PI1Symbol)
sql=cdbl(GoalTarget) &  trim(PI1Symbol) &    cdbl(PI1Value)
if  eval(sql ) then
	testit =1
	else
	testit =0
end if

end function


%>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of nishant joshi
nishant joshi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davidi1

ASKER

used your method to create a Stored Proc..,