Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

ASP Syntax error in date in query expression

[es] :: Visual Basic 6 :: ASP Syntax error in date in query expression

[ Pregleda: 2762 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Kekc
Slovenija

Član broj: 31506
Poruke: 13
*.dial-up.dsl.siol.net.



Profil

icon ASP Syntax error in date in query expression 20.10.2005. u 23:18 - pre 225 meseci
Molim Vas, ako neko ima rešenje za ovo greško:

Error Type:
Microsoft JET Database Engine (0x80040E07)
Syntax error in date in query expression 'calendarDate = #1.10.2005#'.
/Herberstein/calendar_02/calendar.asp, line 139


A koda je:

Code:
<%@ Language=VBScript %>
<%  Option Explicit %>
<% 

' ---------- Author Information ----------
' Written By: Jon Akelaitis
' Copyright 2001 All Rights Reserved
' Web Page: http://www.phoenixs.info
' ICQ: 14664736
' Email: [email protected]
' This set of comments is not to be altered or removed

' ---------- Page Functions ----------
    Function FormatStr(String)
      ' Replaces a double carrige return with a paragraph break
      ' a single carrige return with a break rule and CHR(13) with nothing
      String = Replace(String, CHR(13), "")
      String = Replace(String, CHR(10) & CHR(10), "</P><P>")
      String = Replace(String, CHR(10), "<BR>")
      FormatStr = String
    End Function

' ---------- Page Variables ----------
    Const intCharToShow = 19        ' The number of characters shown in each day
    Const bolEditable   = True        ' If the calendar is editable or not (Can be tied into password verification)

    Dim dtToday             ' Today's Date
    Dim dtCurrentDate            ' The current date
    Dim aCalendarDays(42)        ' Array of possible calendar dates
    Dim iFirstDayOfMonth        ' The first day of the month
    Dim iDaysInMonth             ' The number of days in the month
    Dim iColumns, iRows    , iDay, iWeek    ' The numer of columns and rows in the table, and counters to print them
    Dim objConn, strConn, strSQL, objRS ' Database Variables
    Dim counter             ' Loop counter
    Dim strNextMonth, strPrevMonth    ' The next and previous month dates
    Dim dailyMsg            ' The message for the day
    Dim dtOnDay                ' The current day being displayed by the loops
    Dim strPage                ' The link that each day takes you too

' ---------- Variable Definitions ----------
    dtToday       = Date()

    If Request("currentDate") <> "" Then
      dtCurrentDate = Request("currentDate")
    Else
      dtCurrentDate = dtToday
    End If

    iFirstDayOfMonth = DatePart("w", DateSerial(Year(dtCurrentDate), Month(dtCurrentDate), 1))
    iDaysInMonth = DatePart("d", DateSerial(Year(dtCurrentDate), Month(dtCurrentDate)+1, 1-1))

    For counter = 1 to iDaysInMonth
      aCalendarDays(counter + iFirstDayOfMonth - 1) = counter
    Next

    iColumns = 7
    iRows    = 6 - Int((42 - (iFirstDayOfMonth + iDaysInMonth)) / 7)

    strPrevMonth = Server.URLEncode(DateAdd("m", -1, dtCurrentDate))
    strNextMonth = Server.URLEncode(DateAdd("m",  1, dtCurrentDate))

' ---------- Drawing the Calendar ----------
%>

<HTML>
<HEAD>
  <TITLE>Caledar - <%= MonthName(Month(dtCurrentDate)) & " " & Year(dtCurrentDate) %></TITLE>
  <STYLE TYPE="text/css">
    <!--
    BODY         {background-color: #FFFFFF; text-align: center; font-size: 12px; font-family: Verdana;}
    A             {text-decoration: none;}
    A:active         {color: #000000;}
    A:visited         {color: #000000;}
    A:link         {color: #000000;}
    A:hover         {color: #D80E0E;}
    .blackBacking   {background-color: #000000;}
    .names         {background-color: #4C5D87; font-size: 13px; color: #FFFFFF; text-decoration: none; text-align:  center; font-family: Verdana; font-weight: bold;}
    .calendarBody   {background-color: #F0F0F0; font-size: 12px; color: #000000; text-decoration: none; text-align:  center; font-family: Verdana;}
    .calCurrentDay  {background-color: #C0C0C0; font-size: 11px; color: #FFFFFF;}
    .calOtherDay    {background-color: #F0F0F0; font-size: 11px; color: #000000;}
    .calNotDay        {background-color: #F0F0F0; font-size: 11px; color: #000000;}
    .calFormMenu    {background-color: #4C5D87; font-size: 13px; color: #FFFFFF; text-decoration: none; text-align:  center; font-family: Verdana; font-weight: bold;}
    -->
  </STYLE>
</HEAD>
<BODY>
  <FORM NAME="pageForm" ACTION="calendar.asp" METHOD="GET">
  <CENTER>
  <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=600 BORDER=0>
    <TR>
      <TD CLASS="blackBacking">
    <TABLE CELLSPACING=1 CELLPADDING=1 BORDER=0 WIDTH=600>
        <TR HEIGHT=30px>
          <TD CLASS="names" HEIGHT=30px COLSPAN=7>
          <A HREF="calendar.asp?currentDate=<%= strPrevMonth %>">&laquo; Prev</A>
          &nbsp;
          <SELECT NAME="currentDate" CLASS="calFormMenu" onChange="pageForm.submit()">
          <% For counter = 1 to 12 %>
            <OPTION VALUE="<%= DateSerial(Year(dtCurrentDate), counter, 1) %>" <% If (DatePart("m", dtCurrentDate) = counter) Then Response.Write "SELECTED"%>><%= MonthName(counter) & " " & Year(dtCurrentDate) %></OPTION>
          <% Next %>
          </SELECT>
          &nbsp;
          <A HREF="calendar.asp?currentDate=<%= strNextMonth %>">Next &raquo;</A> 
            </TD>
          </TR>
      <!-- Writring the days of the week for headers -->
          <TR VALIGN="TOP" ALIGN="CENTER">
            <% For iDay = vbSunday To vbSaturday %>
            <TD WIDTH="14%" class="names"><%= WeekDayName(iDay, True) %>.</TD>
            <% Next %>
          </TR>
<%
    Set objConn = Server.CreateObject("ADODB.Connection") 
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("db.mdb") & ";Persist Security Info=False;"
    objConn.Open(strConn) 

    For iWeek = 1 To iRows
      Response.Write "<TR VALIGN=TOP>"
      For iDay = 1 To iColumns
    ' Checks to see if there is a day this month on the date being written
    If aCalendarDays((iWeek-1)*7 + iDay) > 0 then
      dtOnDay = DateSerial(Year(dtCurrentDate), Month(dtCurrentDate), aCalendarDays((iWeek-1)*7 + iDay))

      ' Checks to see if the day being printed is today
      If dtOnDay = dtToday Then
        Response.Write "<TD HEIGHT=55 CLASS='calCurrentDay'>"
       Else
           Response.Write "<TD HEIGHT=55 CLASS='calOtherDay'>"
       End If

      ' Checks to see the type of calendar (editable or non-editable)
       If (bolEditable) then
           strPage = "updateCalendar_form.asp?currentDate=" & dtOnDay
       Else
           strPage = "viewDay.asp?currentDate=" & dtOnDay
      End If

      ' Checks for a message on the day being written
      strSQL = "SELECT * FROM calendar WHERE calendarDate = #" & dtOnDay & "#"
      Set objRS = objConn.Execute(strSQL)
      If NOT objRS.EOF Then 
        dailyMsg = objRS("calendarText")
      Else 
        dailyMsg = ""
      End If
      Set objRS = Nothing

      ' Checks to see if the message is too long to be displayed in the mini date box
          If (Trim(dailyMsg) = Trim(Left(dailyMsg, intCharToShow))) Then
      Else 
         dailyMsg = Trim(Left(dailyMsg, intCharToShow-4)) & " ..."
          End If

       Response.Write ("<A HREF=""" & strPage & """>&nbsp;" & aCalendarDays((iWeek-1)*7 + iDay) & "<BR>&nbsp;&nbsp;" & FormatStr(dailyMsg) & "</A>")
    Else 
      Response.Write ("<TD HEIGHT=50 CLASS='calNotDay'>&nbsp;")
    End IF

    Response.Write "</TD>"
      Next
      Response.Write "</TR>"
    Next

    objConn.Close
    set objConn = Nothing
%>

    </TABLE>
      </TD>
    </TR>
  </TABLE>
<%
    ' Notification for the user to know that the calendar is editable
    If (bolEditable) Then Response.Write "EDITABLE CALENDAR<BR>"
%>
  </FORM>

  <!-- The follow code is not to be removed -->
  <FONT COLOR="#000000" FACE="Verdana" SIZE="1">
  Copyright &copy; 2001. All Rights Reserved.<BR>
  Written By: <A HREF="mailto:[email protected]">Jon Akelaitis</A>
  </FONT>
  <!-- The above code is not to be removed -->

  </CENTER>
</BODY>
</HTML>


Kolko se meni čini, problem je u formatu datuma, koda je napravljena za engleski format, a ja imam slovenski. Več sam stavio LCID, a ne pomaže.


Shadowed: dodati [code] tagovi]

[Ovu poruku je menjao Shadowed dana 21.10.2005. u 09:41 GMT+1]
 
Odgovor na temu

vujkev
Beograd

Član broj: 8072
Poruke: 1347
*.telekom.yu.



+104 Profil

icon Re: ASP Syntax error in date in query expression 09.11.2005. u 11:44 - pre 225 meseci
Prilikom pretrage baze po datumu promenljiva mora da bude u formatu "mm-dd-yyyy" tako da ovu liniju
Code:

strSQL = "SELECT * FROM calendar WHERE calendarDate = #" & dtOnDay & "#"

moraš da zameniš sa
Code:

strSQL = "SELECT * FROM calendar WHERE calendarDate = #" & Month(dtCurrentDate) & "-" & aCalendarDays((iWeek-1)*7 + iDay) & "-" & Year(dtCurrentDate) & "#"



[Ovu poruku je menjao vujkev dana 09.11.2005. u 12:45 GMT+1]
Naučio sam...
Da je važnije biti ljubazan nego biti u pravu
 
Odgovor na temu

branimir.ts
Beograd

Član broj: 56661
Poruke: 127
*.

Sajt: www.geocities.com/brankob..


Profil

icon Re: ASP Syntax error in date in query expression 09.11.2005. u 11:46 - pre 225 meseci
Pokusaj da zamenis konekcioni string , dodaj odgovarajuci parametar tako da koristi Regional Settings ( pogledaj dokumentaciju za MS OLE DB)
 
Odgovor na temu

[es] :: Visual Basic 6 :: ASP Syntax error in date in query expression

[ Pregleda: 2762 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.