добавление нового идентификатора и данных в ASP classic - PullRequest
1 голос
/ 23 августа 2011

Я только что унаследовал древний сайт, написанный на классическом ASP. Необходимо в срочном порядке обновить сайт (хотя они готовятся запустить совершенно новый сайт через несколько месяцев).

После всех этих лет код является беспорядком. У меня нет предварительных знаний об этом языке, но я понимаю суть, с основными страницами, вызывающими .asp включает и все это. В основном просто. Моя работа заключается в обновлении некоторых графиков и карт. Я был почти до финиша, когда столкнулся с проблемой последнего, на этой странице, где я получаю сообщение об ошибке базы данных:

http://test.bigbluebus.com/busroutes/map/index.asp?routeid=1010

Это должно отображать информацию, аналогичную ссылке ниже (хотя, очевидно, для маршрута 10, а не для маршрута 7):

http://test.bigbluebus.com/busroutes/map/index.asp?routeid=77

Проблема, с которой я столкнулся, такова: 10-я линия «Маршрут» меняется на 10-ю «Быстрая». Существующее соглашение об именах - или, по крайней мере, соглашение, которое они используют для предоставления идентификаторов для маршрутов, - это использование номера маршрута для обычной линии / маршрута и использование повторного номера для быстрого маршрута. Например, Маршрут 7 использовал идентификатор «7», в то время как Rapid 7 использует идентификатор «77». Имея это в виду, я назначил Rapid версию маршрута 10 с идентификатором «1010». Это прекрасно работает для графиков (ссылки, расположенные в левой колонке).

Но, очевидно, он разваливается на карты. Я смотрел на это со всех сторон, которые только мог придумать, и я не знаю, что могло вызвать эту проблему Но поскольку я ничего не знаю об ASP, это вряд ли удивительно.

Я связал ссылку «Быстрый 10» в левом столбце с routeid 1010, и в строке 151 index.asp, на которую она ссылается, я просто изменил:

<% if introuteid <> 33 AND  introuteid <> 77 AND introuteid <> 111 then %>

до

<% if introuteid <> 33 AND  introuteid <> 77 AND introuteid <> 111 AND introuteid <> 1010 then %>

Простое добавление 1010 к строке (если это то, что вы даже называете ... Будьте осторожны с новичком, друзьями и соседями), которое, кажется, имеет дело с быстрыми линиями. Смейтесь, если нужно, но эта техника сработала до сих пор! ;)

Используя приведенную выше ссылку на Rapid & в качестве рабочего примера, кто-нибудь может сказать мне, почему Rapid 10 не работает? Это как-то берет эту информацию карты из базы данных (к которой у меня не будет доступа)?

Любое руководство будет с благодарностью. О да, и завтра мой крайний срок. Глоток.

Вот полный код страницы - она ​​разбивается только на 1010 (быстрый 10):

<% 
   Option Explicit
%>

<% if Request.QueryString("routeid") = "" or not (IsNumeric(Request.QueryString("routeid"))) or Request.QueryString("routeid")=11 then
    response.Redirect "../index.asp"
else
    dim introuteid
    set introuteid=request.QueryString("routeid")
end if%>


<!-- #include file="../../datastore.asp" -->
<% dim m
m=2
dim param%>

<%
dim position, line, dayofweek
position="map"
line=introuteid
dayofweek=""
%>

<script language="javascript">
function winopen(urlname, winname, feature) {
    window.open(urlname, winname, feature);
}
</script>

<html>
<head>
<title>Welcome to the Big Blue Bus</title>
</head>

<body background="../../_images/common/bbb_site_bckgd_1800x000.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="744" border="0" cellspacing="0" cellpadding="0" height="100%" valign="baseline" align="left">
<tr>
    <td colspan="2" width="744" valign="top">
        <!-- #include file="../lib/header.asp" -->
    </td>
</tr>
<tr> 
    <td width="176" height="100%" valign="top">
        <!-- #include file="../../lib/busroutelefthandbar.asp" -->
    </td>
    <td width="501" valign="top" align="left">  
    <table width="501" border="0" cellspacing="0" cellpadding="0">                          
    <tr>
        <td colspan="3">&nbsp;

        </td>
    </tr>
        <tr>
        <td colspan="3">
        <font face=<%=application("face_primary")%> size=<%=application("size_large")%> color=<%=application("Color_title")%> >  
        <b>Line Map</b><br>
        </font>
    <% if introuteid = 7 then %>
        <!--<img src="../../_images\new_images\super7.gif" border="0">--><br>
    <% elseif introuteid = 10 then %>
        <!--<img src="../../_images\new_images\10express.gif" border="0"><br><br> -->
    <% elseif introuteid = 0 then %>
        <img src="../../_images\new_images\super12.gif" border="0"><br><br>

    <% elseif introuteid = 33 then %>
        <img src="../../_images\new_images\rapid3Icon.gif" border="0"><br>  

    <% elseif introuteid = 77 then %>
        <img src="../../_images\new_images\rapid7Icon.gif" border="0"><br>  

    <% elseif introuteid = 1010 then %>
                            <img src="../../_images\new_images\rapid10Icon.gif" border="0"><br>

    <% end if %>

        <%' if introuteid = 0 or introuteid = 2 or introuteid = 9 or introuteid = 10 or introuteid = 11 or introuteid = 14 then %>
            <!-- <font face=<%'=application("face_primary")%> size=<%'=application("size_primary")%>>
            Effective September 8, 2002<br><br>
            </font> -->
        <%' end if %>
        </td>
    </tr>
    <%Dim objCommand5, objRs0 
                        Set objCommand5 = Server.CreateObject("ADODB.Command")
                        objCommand5.ActiveConnection = strConnect
                        objCommand5.CommandText = "select name  "&_
                                                  "from tblbusroute "&_
                                                  "where routeid = ?"
                        objCommand5.CommandType = adCmdText
                        Set param = objCommand5.CreateParameter("routeid", adInteger, adParamInput, 4, trim(request.querystring("routeid")))
                        objCommand5.Parameters.Append(param)

                        Set objRS0 = objCommand5.Execute
                        'Set objCommand5 = Nothing%>

    <tr>
        <td colspan="3">
        <table width="507" border="1" cellspacing="0" cellpadding="0" bordercolor=<%=application("bgcolor")%>>                          
        <tr>
            <td bgcolor=<%=application("bgcolor")%> >
            <font face=<%=application("face_primary")%> size=<%=application("size_large")%> color=<%=application("Color_white")%> >  
            <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=objRS0("name")%></b>
            </font>
            <% Set objRS0 = Nothing %>
            </td>
        </tr>
        <tr>
            <td>
            <table width="507" border="0" cellspacing="2" cellpadding="4">                          
            <tr>
                <td valign="center" width="50%"n bgcolor=<%=application("Color_lightblue")%>>
                <font valign="center" face=<%=application("face_primary")%> size=<%=application("size_primary")%>>  
                <center>DETAILED INFORMATION</center>
                </font>
                </td>
                <td valign="center" width="50%"  bgcolor=<%=application("Color_lightblue")%>>
                <font face=<%=application("face_primary")%> size=<%=application("size_primary")%>>  
                <center>SCHEDULE</center>
                </font>
                </td>
            </tr>
            <tr>
                <td  valign="top">
                <font face=<%=application("face_primary")%> size=<%=application("size_secondary")%>>
                <center><b><a href="../location/index.asp?routeid=<%=introuteid%>">Stop Locations</b></a>&nbsp;|&nbsp;Map&nbsp;|&nbsp;<a href="../destination/index.asp?routeid=<%=introuteid%>">Destinations</a></center>
                </font>
                </td>
                <td width="52%" valign="top" align="left">
                <font face=<%=application("face_primary")%> size=<%=application("size_secondary")%>>
                <center><a href="../../busroutes/schedule.asp?bus_route=<%=introuteid%>&dayofweek=weekdays">Monday-Friday</a>&nbsp;|&nbsp;<a href="../../busroutes/schedule.asp?bus_route=<%=introuteid%>&dayofweek=saturday">Saturday</a>&nbsp;|&nbsp;<a href="../../busroutes/schedule.asp?bus_route=<%=introuteid%>&dayofweek=sunday">Sunday/Holidays</a></center>
                </font>
                </td>
            </tr>
            </table>
            </td>
        </tr>
        </table>
        </td>
    </tr>
    <tr>            
        <td colspan="3">&nbsp;

        </td>
    </tr>
    <!-----------end of bus routes navigations--------------->
    <!----------beginning of Stop Loacation--------------------->
    <tr>
        <td valign="top" width="222">

        <% if introuteid <> 33 AND  introuteid <> 77 AND introuteid <> 111 AND introuteid <> 1010 then %>

        <table width="212" border="0" cellspacing="0" cellpadding="0" bordercolor=<%=application("bgcolor")%>>                          
            <tr>
                <td>
                <font face=<%=application("face_primary")%> size=<%=application("size_large")%> color=<%=application("Color_title")%> >  
                <b>Places to Go</b>
                </font>
                </td>
            </tr>
            <tr>
                <td>
                    <table border="0" cellspacing="2" cellpadding="0">
                    <tr>
                        <td width="46%" valign="top">
                        <font face=<%=application("face_secondary")%> size=<%=application("size_secondary")%> color="red"><b>*</b></font>
                        <font face=<%=application("face_primary")%> size=<%=application("size_primary")%>>indicates closest service to destination<br></font>                   
                        </td>
                    </tr>       
                        <%Dim  objRs6 
                        Set objCommand5 = Server.CreateObject("ADODB.Command")
                        objCommand5.ActiveConnection = strConnect

                        objCommand5.CommandText = "select tblplace.placeid as placeid, "&_
                                                  "tblplace.name as name, "&_
                                                  "tblplace.address as address, "&_
                                                  "tblplace.zip as zip, "&_
                                                  "tblplace.phone as phone, "&_
                                                  "tblplace.description as description, "&_
                                                  "tbl_places_to_go_category.categoryname as categoryname, "&_
                                                  "tbl_places_to_go_category.placestogocategoryid as placestogocategoryid, "&_
                                                  "tblplace_busroute.closeroute as closeroute "&_
                                                  "from tblplace, tbl_places_to_go_category, tblplace_busroute "&_
                                                  "where tblplace_busroute.routeid = ? "&_
                                                  "and tblplace_busroute.placeid=tblplace.placeid and "&_
                                                  "tblplace.placestogocategoryid=tbl_places_to_go_category.placestogocategoryid "&_
                                                  "order by placestogocategoryid, name"



                        objCommand5.CommandType = adCmdText
                        Set param = objCommand5.CreateParameter("routeid", adInteger, adParamInput, 4, trim(request.querystring("routeid")))
                        objCommand5.Parameters.Append(param)

                        Set objRS6 = objCommand5.Execute
                        Set objCommand5 = Nothing%>

                        <% dim strcompareCategory 
                        strcompareCategory=""%>
                        <% dim strcomparename 
                        strcomparename=""%>

                        <%while not objRS6.eof%>
                        <%if strcompareCategory<>"" and strcompareCategory <> trim(objRS6("categoryname")) then%>
                            </td>
                            </tr>
                        <%end if%>
                        <% if strcompareCategory="" or trim(strcompareCategory) <> trim(objRS6("categoryname")) then%>
                        <tr>
                            <td valign="center"  width="50%">
                            <br><font face=<%=application("face_primary")%> size=<%=application("size_primary")%> color=<%=application("Color_title")%>>  
                            <b><%=objRS6("categoryname")%></b>
                            </font>
                            <%strcompareCategory = trim(objRS6("categoryname"))%>
                            </td>
                        </tr>
                        <tr>
                            <td width="46%" valign="top">
                            <font face=<%=application("face_primary")%> size=<%=application("size_primary")%>>
                            <a href="javascript:winopen('placestogodetail.asp?placeid=<%=trim(objRS6("placeid"))%>','glossarywindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=400,top=20,left=20')">
                            <%=objRS6("name")%></a><% if trim(objRS6("closeroute")) = "yes" then%><font face=<%=application("face_secondary")%> size=<%=application("size_secondary")%> color="red"><b>*</b></font><%end if%><br>
                            </font>
                            <% strcomparename = objRS6("name")%>
                        <%else%>
                            <% if strcomparename <> objRS6("name") then%>   
                                <font face=<%=application("face_primary")%> size=<%=application("size_primary")%>>
                                <a href="javascript:winopen('placestogodetail.asp?placeid=<%=trim(objRS6("placeid"))%>','glossarywindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=400,top=20,left=20')">
                                <%=objRS6("name")%></a><% if trim(objRS6("closeroute")) = "yes" then%><font face=<%=application("face_secondary")%> size=<%=application("size_secondary")%> color="red"><b>*</b></font><%end if%><br>
                                </font>
                                <%strcompareCategory = trim(objRS6("categoryname"))%>
                                <% strcomparename = objRS6("name")%>
                            <% end if%> 
                        <%end if%>
                            <%objRS6.movenext%> 
                        <%wend%>    
                        <%objRS6.close%>
                        <%set objRs6 = nothing%>    
                        </td>
                    </tr>
                </table>
                </td>
            </tr>
        </table>

        <% End If %>

        </td>   
        <td>&nbsp;

        </td>
        <td valign="top" width="279">
        <table width="279" border="0" cellspacing="0" cellpadding="0" bordercolor=<%=application("bgcolor")%>>                          
            <tr>
                <td align="center">
                <img src="../../_images/busroutes/map<%=introuteid%>.gif"  alt="" >
                </td>
            </tr>
        </table>    
        </td>
    </tr>
    <!----------End of Stop Loacation---------------------> 
    <tr>
        <td>&nbsp;

        </td>
    </tr>
    <% if introuteid = 11 or introuteid = 101 then %>
    <tr>
        <td colspan="3">
                <font face=<%=application("face_primary")%> size=<%=application("size_primary")%>>
                    Anyone may ride the SMC Commuter route, but Santa Monica College Students/Staff may ride at no cost upon presentation of a valid SMC ID card. Big Blue Bus fares apply to anyone who cannot present a valid SMC ID card.<br><br>
                </font>
        </td>
    </tr>
    <% end if %>
    </table>
    </td>
</tr>
<tr>
    <td colspan="2" width="744" bgcolor=<%=application("bgcolor")%> height="1%" valigh="top">
    <!-- #include file="../lib/footer.asp" -->
    </td>
</tr>
<tr>
    <td colspan="2" width="744" bgcolor="<%=Application("bgcolor")%>" height="1%">&nbsp;

    </td>
</tr>
</table>
</body>
</html>

Ответы [ 2 ]

2 голосов
/ 23 августа 2011

Да, похоже, данные поступают из базы данных, ADODB.Command используется для выдачи запроса в базу данных и для возврата данных из нее. Проблема, которая возникает в вашем случае, заключается в том, что запрос ничего не возвращает (я не знаю структуру вашей базы данных, но эта ошибка очевидна)

Таким образом, вы должны проверить в запросе, все ли в порядке, или в базе данных, если данные существуют. Если все это проверено и все в порядке, это просто означает, что этот запрос возвращает пустое значение, а затем делает проверку перед отображением данных, чтобы увидеть, является ли набор записей пустым, как это:

If Not objRS0.EOF Then

' Do something

End If

Кстати, объекты команд и наборов записей имеют плохое имя (objRS0, objRS6), я предлагаю вам изменить их на более подходящие имена.

0 голосов
/ 24 августа 2011

Проблема в том, что вы ищете название автобусного маршрута в базе данных, в соответствии с идентификатором.Таблица "tblbusroute" не имеет соответствующего имени для маршрута с идентификатором 1010, поэтому возникает ошибка.

Чтобы исправить это, необходимо слегка изменить код.Во-первых, прямо сейчас у вас есть эта строка:

Set objRS0 = objCommand5.Execute

Измените эту одну строку, чтобы стать этим блоком кода вместо:

Dim sBusRouteName
Set objRS0 = objCommand5.Execute
If objRS0.EOF Then
    sBusRouteName = "Route " & request.querystring("routeid")
Else  
    sBusRouteName = objRS0("name")
End If

Это поместит правильное имя в переменную, даже если этов базе данных, затем далее в коде, измените это:

<%=objRS0("name")%>

Вместо этого:

<%=sBusRouteName%>

И оно покажет правильное имя без сбоев.

...