-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