[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Record displaying twice

Posted on 2004-11-06
11
Medium Priority
?
304 Views
Last Modified: 2008-03-10
Im using asp and sql on a iis host . My whole site works fine except it dispays the same record twice on a report.asp page. It has the same ID and only shows up once in the
access database.
0
Comment
Question by:tmurray22
  • 2
  • 2
  • 2
  • +5
11 Comments
 
LVL 30

Expert Comment

by:VirusMinus
ID: 12515834
posting your code may help;

Also is it the last record in a loop?

If yes then adding the following may help ->

While NOT rs.EOF

 '... Display your info ...

 If Not rs.EOF then
   rs.Movenext
 End if

Wend
0
 
LVL 4

Expert Comment

by:sprisoner
ID: 12515961
one more reason may be JOINs, if there are any in the query. so as VirusMinus says, little it of ur code can help us catch the bug.

Nash
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 12516100
Maybe you have Records Recorded Twice in Database?

Try Running your SQL statement with DISTINCT keyworks

Selecr DISTINCT COL1, COL2 From TableName
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Expert Comment

by:apresto
ID: 12516765
i think he said it only in the db once but wouldnt hurt to check i suppose.  Make sure you have a field that is the primary key as this uniquely identifies a record.  I tihnk virusminus is right aswell, sounds like a loop.  Make sure if you have this line in your code:

rs.movefirst

It is after an IF but BEFORE a while
0
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 12517908
r u using a Join Statement ?.. if u r joining 2 tables. it can be twice in one of the Tables

Melih SARICa
0
 
LVL 19

Expert Comment

by:peh803
ID: 12518124
If you're still unable to fix your problem given the posts above, please post your code.

Thanks,
peh803
0
 

Author Comment

by:tmurray22
ID: 12520460
There is only one record recorded in datbase. The records that display twice are actually referring to the same record. Here is a sample link that shows both having
the same unique ID.

http://pysdoorway/scm/scheduler/mc25/manage/event_view.asp?ID=90


Here is the code for the page that displays the entries.
Below that is the page with the SQL that qualifies the records to be displayed.



'Calendar.ASP

<!--#include file="../config.asp"-->

<% Dim C_MONTH, C_YEAR, C_FIRSTD, C_CRD, I, C_CRDATE, SEL_CATE, sUW, blTODAY
       With Request
            C_MONTH  = Trim(.Querystring("Month"))
            C_YEAR   = Trim(.Querystring("Year"))
            SEL_CATE = Trim(.QueryString("cate"))
       End With
             
       IF (Len(C_MONTH) = 0) OR (C_MONTH = "") OR (IsNull(C_MONTH)) then C_MONTH = Month(Date)
       IF (Len(C_YEAR)  = 0) OR (C_YEAR = "") OR (IsNull(C_YEAR)) then C_YEAR = Year(Date)
     IF IS_VALID_ID(C_MONTH) = False THEN C_MONTH = Month(Date)
     IF IS_VALID_ID(C_YEAR) = False THEN C_MONTH = Year(Date)
     IF NOT (SEL_CATE = "0" OR IS_VALID_ID(SEL_CATE) = True) THEN SEL_CATE = "0"
       C_FIRSTD = WeekDay(DateSerial(C_YEAR, C_MONTH, 1)) -1       
       C_CRD = 0       
     
      %>

      <!--#include file="inc_functions.asp"-->
      <!--#include file="../inc_api.asp"-->
      <!--#include file="inc_header.asp"-->
      
      <%
       Call OPEN_DB()
     sUW = Trim(RETURN_CAL_SET(False, "fldUW", Session("C_ID")))
     IF sUW = "1" THEN
        USE_WEEKNUM = True
     ELSE
        USE_WEEKNUM = False    
     END IF
     
        Call INC_C_DROPS()
       Call INC_C_HEADER(C_MONTH, C_YEAR)       
      
            FOR I = 1 TO LastDay(C_MONTH, C_YEAR)
                  C_CRD = C_CRD + 1
                  If (Trim(C_MONTH) = Trim(Month(Date))) AND (Trim(Day(Date)) = Trim(C_CRD)) Then
                blTODAY = True
            else
                blTODAY = False
            end if    
            C_CRDATE = ASDATE(C_MONTH, C_CRD, C_YEAR)            
            C_CRDATE = FormatDateTime(C_CRDATE,2)
           
                  %>
                  <tr>
                        <td bgcolor="#F7F7F7" width="70" valign="top"><% If blTODAY = True Then %><font color="black"><b><%=arrDAYNAMES(Weekday(C_CRDATE)-1)%></b></font><%Else%><%=arrDAYNAMES(Weekday(C_CRDATE)-1)%><%End If%></td>
                        <td align="center" bgcolor="#F7F7F7" width="25" valign="top"><% If blTODAY = True Then %><font color="black"><b><%=C_CRD%></b></font><%Else%><%=C_CRD%><%End If%></td>
                <%If USE_WEEKNUM = True Then%><td align="center" bgcolor="#F7F7F7" width="25" valign="top"><%=GET_WEEK_NUMBER(C_CRDATE)%></td><%End If%>
                        <td width="100%" valign="top">
                    <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>
                          <td width="13"><a href="event_add.asp?qmode=1&m=<%= C_MONTH %>&d=<%= C_CRD %>&y=<%= C_YEAR %>"><img src="../images/ico_plus.gif" width="13" height="13" alt="Add New Reservation" border="0" /></a></td>
                          <td><%=CHECK_EVENTS(False, Session("C_ID"), C_CRDATE)%></td>
                    </tr></table>
                </td>
                  </tr>            
                  <%
            NEXT
      
            
       Call INC_C_FOOTER()
       MyConn.Close
       Set MyConn = Nothing      

%><!--#include file="inc_footer.asp"-->




'inc_functions.asp

<%
FUNCTION CHECK_EVENTS_ALLCALS(OPEN, ID, sDATE)
Dim E_TITLE, E_ID, SQL, E_COLOR, intWEEKDAY, blFOUND, strCATE_SQL, STIME, ETIME, strTIME, sQ, MID_SQL, C_NAME
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      blFOUND = False
      intWEEKDAY = Weekday(sDATE)
      IF (SEL_CATE = "") OR (IsNull(SEL_CATE)) OR (SEL_CATE = "0") THEN
            SEL_CATE = ""
      ELSE
            strCATE_SQL = " AND (mc_tbl_event.fldCATE_ID=" & SEL_CATE & ")"
      END IF
      '----------------------------------------'
    IF CALSIDS = "" OR IsNUll(CALSIDS) THEN ' SHOW ALL CALENDARS
        IF SHOWN = "1" THEN ' SHOW CALENDAR NAME
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            ELSE
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            END IF
        ELSE
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            ELSE            
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_calendar.fldACTIVE = 1) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                    "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            END IF
        END IF            
      ELSE ' SHOW ONLY DESIRED CALENDARS
       
        MID_SQL = "AND ("
        FOR sQ = 0 TO Ubound(arrCALSIDS)
            IF Not ((Trim(arrCALSIDS(sQ)) = "") OR (IsNUll(arrCALSIDS(sQ)))) THEN                
                    MID_SQL = MID_SQL & "(mc_tbl_event.fldCAL_ID = " & Trim(arrCALSIDS(sQ)) & ") OR "                 
            END IF
        NEXT            
        MID_SQL = Mid(MID_SQL,1,Len(MID_SQL)-3)
            MID_SQL = MID_SQL & ") "
       
        IF SHOWN = "1" THEN ' SHOW CALENDAR NAME
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME  FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"    
            ELSE
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME, mc_tbl_calendar.fldNAME AS C_NAME  FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_calendar.ID = mc_tbl_event.fldCAL_ID)" & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"            
            END IF
        ELSE
            IF DB_TO_USE = 1 THEN ' MS Access
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (Now() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"            
            ELSE
                    SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate, mc_tbl_calendar WHERE " & _
                    "(mc_tbl_event.fldACTIVE = 1) " & MID_SQL & _
                "AND (mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID)" & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
                "AND (GetDate() < (mc_tbl_calendar.fldSINCE+mc_tbl_calendar.fldEXP_IN))" & _
                  "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                    "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"
            END IF
        END IF            
    END IF
   
'    response.write SHOWN & "<br>" & SQL
'    response.End
   
          Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         E_TITLE = trim(RS("E_TITLE"))
                        E_ID    = trim(RS("E_ID"))
                        E_COLOR = trim(RS("E_COLOR"))
                        STIME = trim(RS("fldSTIME"))
                        ETIME = trim(RS("fldETIME"))
                IF SHOWN = "1" THEN C_NAME = trim(RS("C_NAME"))                
                        '--------------------------'
                        IF NOT ((STIME = "") OR (ETIME = "")) THEN
                              strTIME = "[" & STIME & "-" & ETIME & "] "
                        ELSE
                              IF ((Trim(ETIME) = "") OR (IsNull(ETIME))) AND ((Trim(STIME) = "") OR (IsNull(STIME))) THEN
                                    strTIME = ""
                              ELSE
                                    IF NOT ((Trim(STIME)="") OR (IsNull(STIME))) THEN
                                          strTIME = "[" & STIME & "] "
                                    ELSE
                                          strTIME = ""      
                                    END IF                                    
                              END IF      
                        END IF      
                        '--------------------------'
                        blFOUND = True
                IDS = IDS & E_ID & ","
                        %>
                        <br /><% IF SHOWN = "1" THEN %><i><%= C_NAME %></i><br /><% End If %><a title="<%= arrCOMMON(1) %>" style="color:<%=E_COLOR%>" href="event_view.asp?EID=<%=E_ID%>&ID=<%=ID%>&cTYPE=<%=cTYPE%>"><%=strTIME%><%=PROCESS_SIGNS(E_TITLE, ID, False)%></a><br />
                        <%
                      RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing
            
            IF cTYPE = "1" THEN
                  IF blFOUND = False Then Response.Write "&nbsp;<br /><br /><br /><br />"            
            ELSE
                  IF blFOUND = False Then Response.Write "&nbsp;"
            END IF      
      '----------------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION


'// PURPOSE:
'          Get calendar name and description
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
'   NOTES:
'          varailable NAME and DES is a declared in calendar.asp
PRIVATE FUNCTION GET_NAME(ID, OPEN)
Dim SQL, RS, strCATE, EXPIN, SINCE
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
            SQL = "SELECT fldNAME, fldDES, fldACTIVE, fldEXP_IN, fldSINCE, fldPUBLIC FROM mc_tbl_calendar WHERE ID = " & ID
            Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1 '// adLockReadOnly
            RS.CursorType = 0  '// adOpenForwardOnly
            RS.Open SQL, MyConn      
                   IF NOT RS.EOF THEN
                         NAME = trim(RS("fldNAME"))
                        DES = trim(RS("fldDES"))
                        ACTIVE = trim(RS("fldACTIVE"))
                EXPIN  = trim(RS("fldEXP_IN"))
                SINCE  = trim(RS("fldSINCE"))
                cPUBLIC = trim(RS("fldPUBLIC"))
                EXPIN = FormatNumber(((CDate(SINCE)+Cdbl(EXPIN)) - Date),0)                
                IF EXPIN =< 0 THEN
                    MESSAGE = MESSAGE & "<li />" & arrERROR(0)
                END IF
                   END IF
            RS.Close
            Set RS = Nothing      
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION

'// PURPOSE:
'          Assemble category dropdown menu
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
PRIVATE FUNCTION GET_CATE_NAMES(ID, OPEN)
Dim SQL, RS, strCATE
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      '-----------------------------------'
            SQL = "SELECT ID, fldNAME, fldCOLOR FROM mc_tbl_cate WHERE (fldACTIVE = 1) AND (fldCAL_ID=" & ID & ") ORDER BY fldNAME ASC"
            Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         If SEL_CATE = trim(RS("ID")) Then                         
                              strCATE = strCATE & "<option style=" & chr(34) & "background-color:" & trim(RS("fldCOLOR")) & Chr(34) & " selected value=" & chr(34) & trim(RS("ID")) & chr(34) & ">" & trim(RS("fldNAME")) & Vbcrlf
                        Else
                              strCATE = strCATE & "<option style=" & chr(34) & "background-color:" & trim(RS("fldCOLOR")) & Chr(34) & " value=" & chr(34) & trim(RS("ID")) & chr(34) & ">" & trim(RS("fldNAME")) & Vbcrlf
                        End If                            
                        RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing            
      '-----------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
      '-----------------------------------'
      IF strCATE = "" THEN strCATE = "<option value=" & chr(34) & "0" & chr(34) & ">N/A" & Vbcrlf
      GET_CATE_NAMES = strCATE
END FUNCTION







'// PURPOSE:
'          Check for events at given date
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
'          sDATE - work with events of passed date
FUNCTION CHECK_EVENTS_SMALL(OPEN, ID, sDATE)
Dim SQL, intWEEKDAY, blFOUND, TOTAL
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      blFOUND = False
      intWEEKDAY = Weekday(sDATE)
        IF DB_TO_USE = 1 THEN ' MS Access
                SQL = "SELECT COUNT(mc_tbl_event.ID) AS TOTAL FROM mc_tbl_event WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _            
              "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)"
        ELSE
                SQL = "SELECT COUNT(mc_tbl_event.ID) AS TOTAL FROM mc_tbl_event WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _            
              "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)"        
        END IF    
            Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         TOTAL = RS("TOTAL")
                        blFOUND = True
                        IF Cint(TOTAL) > 0 THEN %>
                              <a href="small_view.asp?ID=<%=ID%>&cd=<%=sDATE%>"><b><%=TOTAL%></b></a><br />
                    <%ELSE%>
                                &nbsp;
                    <%END IF                        
                      RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing
            IF blFOUND = False Then Response.Write "&nbsp;"            
      '----------------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION

'// PURPOSE:
'          Check for events at given date
'   PARAMS:
'          OPEN  - [True/Flase]  - Open Database Connection
'          ID    - ID of calendar
'          sDATE - work with events of passed date
FUNCTION CHECK_EVENTS(OPEN, ID, sDATE)
Dim E_TITLE, E_ID, SQL, E_COLOR, intWEEKDAY, blFOUND, strCATE_SQL, STIME, ETIME, strTIME
      IF OPEN = True THEN
            Call OPEN_DB()
      END IF
      blFOUND = False
      intWEEKDAY = Weekday(sDATE)
      IF (SEL_CATE = "") OR (IsNull(SEL_CATE)) OR (SEL_CATE = "0") THEN
            SEL_CATE = ""
      ELSE
            strCATE_SQL = " AND (mc_tbl_event.fldCATE_ID=" & SEL_CATE & ")"
      END IF
          IF DB_TO_USE = 1 THEN ' MS Access
                SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
              "AND (#" & sDATE & "# BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"    
        ELSE
                SQL = "SELECT mc_tbl_event.ID AS E_ID, mc_tbl_event.fldTITLE AS E_TITLE, mc_tbl_cate.fldCOLOR AS E_COLOR, fldSTIME, fldETIME FROM mc_tbl_event, mc_tbl_cate WHERE " & _
                "(mc_tbl_event.fldCAL_ID = " & ID & ") " & _
                "AND (mc_tbl_event.fldACTIVE = 1) " & _
                "AND (mc_tbl_event.fldCATE_ID = mc_tbl_cate.ID) " & _
              "AND ('" & sDATE & "' BETWEEN mc_tbl_event.fldSDATE AND mc_tbl_event.fldEDATE) " & _
                "AND " & intWEEKDAY & " IN (SELECT fldDAY FROM mc_tbl_event_week WHERE fldEVENT_ID = mc_tbl_event.ID)" & strCATE_SQL & " ORDER BY fldSTIME, fldTITLE ASC"            
        END IF    
          Set RS = Server.CreateObject("ADODB.Recordset")
            RS.LockType   = 1
            RS.CursorType = 0
            RS.Open SQL, MyConn      
                   WHILE NOT RS.EOF
                         E_TITLE = trim(RS("E_TITLE"))
                        E_ID    = trim(RS("E_ID"))
                        E_COLOR = trim(RS("E_COLOR"))
                        STIME = trim(RS("fldSTIME"))
                        ETIME = trim(RS("fldETIME"))
                        '--------------------------'
                        IF NOT ((STIME = "") OR (ETIME = "")) THEN
                              strTIME = "[" & STIME & "-" & ETIME & "] "
                        ELSE
                              IF ((Trim(ETIME) = "") OR (IsNull(ETIME))) AND ((Trim(STIME) = "") OR (IsNull(STIME))) THEN
                                    strTIME = ""
                              ELSE
                                    IF NOT ((Trim(STIME)="") OR (IsNull(STIME))) THEN
                                          strTIME = "[" & STIME & "] "
                                    ELSE
                                          strTIME = ""      
                                    END IF                                    
                              END IF      
                        END IF      
                        '--------------------------'
                        blFOUND = True
                IDS = IDS & E_ID & ","
                        %>
                        <a title="<%= arrCOMMON(1) %>" style="color:<%=E_COLOR%>" href="event_view.asp?EID=<%=E_ID%>&ID=<%=ID%>&cTYPE=<%=cTYPE%>"><%=strTIME%><%=PROCESS_SIGNS(E_TITLE, ID, False)%></a><br />
                        <%
                      RS.MoveNext
                   WEND
            RS.Close
            Set RS = Nothing
            
            IF cTYPE = "1" THEN
                  IF blFOUND = False Then Response.Write "&nbsp;<br /><br /><br /><br />"            
            ELSE
                  IF blFOUND = False Then Response.Write "&nbsp;"
            END IF      
      '----------------------------------------'
      IF OPEN = True THEN
            MyConn.Close
            Set MyConn = Nothing      
      END IF      
END FUNCTION

'// PURPOSE:
'          Draw begining of the calendar, with navigation
PRIVATE SUB INC_C_HEADER_SMALL(C_MONTH,C_YEAR)   %>
      <table border="1" cellspacing="0" cellpadding="2" width="200" align="center" bordercolor="#dadada">
        <tr bgcolor="WhiteSmoke">
            <td colspan="7" background="images/bg1.gif">
                  <% Call INSERT_NAVIG_SMALL %>
            </td>
        </tr>      <%
END SUB
'// PURPOSE:
'          Draw begining of the calendar, with navigation
PRIVATE SUB INC_C_HEADER(C_MONTH,C_YEAR)   %>
      <table border="1" cellspacing="0" cellpadding="2" width="550" align="center" bordercolor="#e5e5e5">
        <tr bgcolor="WhiteSmoke">
            <td colspan="7">
                  <% Call INSERT_NAVIG %>
            </td>
        </tr>      <%
END SUB

'// PURPOSE:
'          Insert top row, containing month name and navig arrows.
PRIVATE SUB INSERT_NAVIG() %>
      <table border="0" cellspacing="1" cellpadding="1" width="100%" class="tblARROWNAVIG"><tr>
      <td align="left" width="15" background="images/bg1.gif">
            <%
        IF ID = "" OR IsnuLL(ID) THEN
                Response.write "<a href = 'all_calendars.asp?"
                IF C_MONTH - 1 = 0 THEN
                      response.write "month=12&year=" & C_YEAR -1 & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH - 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_left.gif' width='15' height='13' border='0'></a>"
        ELSE
                Response.write "<a href = 'calendar.asp?"
                IF C_MONTH - 1 = 0 THEN
                      response.write "month=12&year=" & C_YEAR -1 & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH - 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_left.gif' width='15' height='13' border='0'></a>"
        END IF    
            %>
      </td><td background="images/bg1.gif" align="center"><%=arrMONTHNAME(C_MONTH-1) & " " & C_YEAR%></td>
      <td align="right" width="15" background="images/bg1.gif">
            <%
        IF ID = "" OR IsnuLL(ID) THEN
                Response.write "<a href = 'all_calendars.asp?"
                IF C_MONTH + 1 = 13 THEN
                      response.write "month=1&year=" & C_YEAR + 1 & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH + 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_right.gif' width='15' height='13' border='0'></a>"
        ELSE
                Response.write "<a href = 'calendar.asp?"
                IF C_MONTH + 1 = 13 THEN
                      response.write "month=1&year=" & C_YEAR + 1 & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                ELSE
                      response.write "month=" & C_MONTH + 1 & "&year=" & C_YEAR & "&cate=" & SEL_CATE & "&ID=" & ID & "&cTYPE=" & cTYPE & "&calsids=" & CALSIDS
                END IF
                Response.write "'><img src='images/arrow_right.gif' width='15' height='13' border='0'></a>"        
        END IF
            %>      
      </td></tr></table> <%
END SUB

'// PURPOSE:
'          Insert top row, containing month name and navig arrows.
PRIVATE SUB INSERT_NAVIG_SMALL() %>
      <table border="0" cellspacing="1" cellpadding="1" width="100%" class="tblARROWNAVIG"><tr>
      <td align="left" width="15" background="images/bg1.gif">
            <%
            Response.write "<a href = 'small.asp?"
            IF C_MONTH - 1 = 0 THEN
                  response.write "month=12&year=" & C_YEAR -1 & "&ID=" & ID
            ELSE
                  response.write "month=" & C_MONTH - 1 & "&year=" & C_YEAR & "&ID=" & ID
            END IF
            Response.write "'><img src='images/arrow_left.gif' width='15' height='13' border='0'></a>"
            %>            
      </td><td align="center" background="images/bg1.gif"><%=arrMONTHNAME(C_MONTH-1) & " " & C_YEAR%></td>
      <td align="right" width="15" background="images/bg1.gif">
            <%
            Response.write "<a href = 'small.asp?"
            IF C_MONTH + 1 = 13 THEN
                  response.write "month=1&year=" & C_YEAR + 1 & "&ID=" & ID
            ELSE
                  response.write "month=" & C_MONTH + 1 & "&year=" & C_YEAR & "&ID=" & ID
            END IF
            Response.write "'><img src='images/arrow_right.gif' width='15' height='13' border='0'></a>"
            %>      
      </td></tr></table> <%
END SUB

'// PURPOSE:
'          Draw last row of calendar table, include naviagation
PRIVATE SUB INC_C_FOOTER()
            %>
            <tr bgcolor="WhiteSmoke">
             <td colspan="7">
                  <% Call INSERT_NAVIG %>
             </td>
            </tr></table>
        <%
END SUB

'// PURPOSE:
'          Draw last row of calendar table, include naviagation
PRIVATE SUB INC_C_FOOTER_SMALL()
            %>
            <tr bgcolor="WhiteSmoke">
             <td colspan="7">
                  <% Call INSERT_NAVIG_SMALL %>
             </td>
            </tr></table>
        <%
END SUB

'// PURPOSE:
'          Draw begining of the calendar, with navigation
PRIVATE SUB INC_C_HEADER_FULL(C_MONTH,C_YEAR)   %>
      <table border="1" cellspacing="0" cellpadding="2" width="550" align="center" bordercolor="#dadada">
        <tr bgcolor="WhiteSmoke">
            <td colspan="<%If USE_WEEKNUM = True Then%>4<%Else%>3<%End If%>">
                  <% Call INSERT_NAVIG %>
            </td>
        </tr>      <%
END SUB

'// PURPOSE:
'          Draw last row of calendar table, include naviagation
PRIVATE SUB INC_C_FOOTER_FULL()
            %>
      <tr bgcolor="WhiteSmoke">
       <td colspan="<%If USE_WEEKNUM = True Then%>4<%Else%>3<%End If%>">
            <% Call INSERT_NAVIG %>
       </td>
      </tr></table>
      <br />
        <%
END SUB
%>
0
 
LVL 19

Expert Comment

by:peh803
ID: 12523534
Holy cow, that's a lotta code!  Are you sure ALL that code is applicable to the part that's showing the same record twice?  Also, I was unable to view your link referenced above for the example...

peh803
0
 
LVL 18

Accepted Solution

by:
SquareHead earned 1500 total points
ID: 12523683
Maybe you've tried this?

Try a response.write on your SQL statement, post it here.

Have you tried executing the SQL statement in SQL View? Does it return one record? If so, the problem is probably in your ASP code. If the SQL returns more than one record, then it's probably the SQL...
0
 
LVL 18

Expert Comment

by:SquareHead
ID: 12523776
In other words, display your entire SQL statement on the screen, then cut & paste into Access' SQL View and execute... See what you get...
0
 

Author Comment

by:tmurray22
ID: 12548798
That did it I posted the different queries until i finally found the one generating the same record twice. It wasreferencing the ID twice before the end of the query.


Thanks
for all your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question