-2
我想在asp中編寫一個「if」語句來以正確的格式獲取我需要在高圖表中提供的數據。ASP IF語句獲取數據
問題1:你們能讓我知道我的if語句有什麼問題嗎? 問題2:如果我想要添加另一個數據集以在條件0的另一個圖表中進行填充,那麼我如何在asp中引用它?我在哪裏放置另一個sql語句?
condition = Split(Request.Form("condition"),"~")
'condition = Split("field1~field2~field3~('field4')~('')~('Field5')~'01/18/2015' and '02/02/2015'~field6", "~")
'0 is the chart type
'1 is chart frequency
'2 company
'3 is place
'4 is shop
'5 is caused
'6 is date range'
'7is top5 type'
'field7~('')~('')~('')~01/18/2015<>01/18/2015~field8'
'' Response.write condition(3)
chartinfo = condition(2)
dateString = ""
if condition(0)<>"Top 5" then
where = "[Type]='" + condition(1) +"'"
if condition(1)<> "Monthly" then
where = where + " and convert(datetime,date,101) between " + condition(6)
end if
if condition(3) <>"('')" then
where = where + " and place in " + condition(3)
chartinfo = chartinfo + ";" + condition(3)
end if
if condition(4) <>"('')" then
where = where + " and Shop in " + condition(4)
chartinfo = chartinfo + ";" + condition(4)
end if
if condition(5) <>"('')" then
where = where + " and [Caused Group] in " + condition(5)
chartinfo = chartinfo + ";" + condition(5)
end if
else
condition(0) = "Top 5" then
where
end if
where = replace(where,"'","''")
sql = "[Data] '" + where + "', '''" + dateString +"''','''"+ chartinfo +"'''"
1.在東西'else'地方怪異。可能是'elseif condition(0)=「Top 5」then「或者保留'else'並且註釋''''condition(0)=」Top 5「then line。你是什麼意思分開'where'?適當的縮進應該有所幫助。 – JosefZ 2015-02-11 09:22:11
xcuse - 如此髒的代碼 – DimaSUN 2015-02-11 21:17:09