Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 Classic ASP - If Statement

Author  Topic 

dzach
Starting Member

38 Posts

Posted - 2008-12-19 : 15:43:24
I have the following ASP code that works fine, up to the IF statement. I'm trying to display an image based on the result of the MachineName variable.

I'm getting "incorrect syntax errors" where the IF statement begins.


Code:

set rsqdb = conn.Execute ("Select MachineName, KPName, Severity, " _
& " EventMSG + '; ' + AgentMsgShort as EventMessages, DateAdd(ss, LastOccurTime-3600, '1969-12-31T18:00:00.000') as OccurTime " _
& " From Event, EventDetail " _
& " Where Severity < 6 " _
& " AND Status = 0 " _
& " AND EventDetail.EventID = Event.EventID " _
& " AND AgentMsgShort <> 'NULL' " _
& " AND CAST(FLOOR(CAST(DATEADD(S,LastOccurTime, '1969-12-31T18:00:00.000') AS FLOAT)) AS DATETIME) >= (getdate() -1 ) " _
& " AND EventMSG NOT LIKE '%Work Queue Length%' " _
& " AND EventMSG NOT LIKE '%DRA Outbound%' " _
& " AND EventMSG NOT LIKE '%Report Creation Failed%' " _
& " AND EventMSG NOT LIKE '%NCOGateway%' " _
& " AND EventMSG NOT LIKE '%Diagnostic Console%' " _
& " AND EventMSG NOT LIKE '%Pdsk%' " _
& " AND EventMSG NOT LIKE '%EventLog does not exist%' " _
& " Order By OccurTime DESC " _

&" If Machinename = 'enpefr' then " _
&" <img src="map10.jpg"> " _
&" end if ")


Any help is appreciated!

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-12-21 : 20:56:56
The part at the end isn't SQL code, it's ASP code. It should not be in quotes and it should not be concatenated with your SQL statement.



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

dzach
Starting Member

38 Posts

Posted - 2008-12-22 : 08:51:54
Thanks!!
Go to Top of Page

jl2
Starting Member

2 Posts

Posted - 2009-01-20 : 11:34:04
I'm pretty new at this stuff, but shoudn't there be a beggining <% and %> to comment the if statement out?
Also, the IF statement's quotes should be double quotes, not single
Go to Top of Page

jayvee88
Starting Member

2 Posts

Posted - 2013-02-24 : 06:40:56
no, the single quote on the string is right, if it's a double then the line ends on the equal sign..
Go to Top of Page
   

- Advertisement -