Results 1 to 10 of 10

Thread: Toublesome Date!

  1. #1
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Toublesome Date!

    <%
    Session.LCID=2057
    %>
    <!--#include file="Connections/connUs.asp" -->
    <%
    Dim rsOnline__MMColParam
    rsOnline__MMColParam = "W"
    If (Request("MM_EmptyValue") <> "") Then
    rsOnline__MMColParam = Request("MM_EmptyValue")
    End If
    %>
    <%
    Dim rsOnline__MMColParam2
    rsOnline__MMColParam2 = "3"
    If (Request.QueryString("status") <> "") Then
    rsOnline__MMColParam2 = Request.QueryString("status")
    End If
    %>
    <%
    Dim rsOnline__MMColParam3
    rsOnline__MMColParam3 = "0"
    If (Request("MM_EmptyValue") <> "") Then
    rsOnline__MMColParam3 = Request("MM_EmptyValue")
    End If
    %>
    <%
    Dim rsOnline__var
    rsOnline__var = "01/11/2005"
    If (Request.QueryString("txtDate") <> "") Then
    rsOnline__var = Request.QueryString("txtDate")
    End If
    %>
    <%
    Dim rsOnline
    Dim rsOnline_numRows

    Set rsOnline = Server.CreateObject("ADODB.Recordset")
    rsOnline.ActiveConnection = MM_connUs_STRING
    rsOnline.Source = "SELECT IONO, DESPNO, SALESVALUE, DELYADDR, UNISTRIP.ORH.CUSTCODE, STATUS, ""DATE"", DATEINPUT, UNISTRIP.CUS.CUSTCODE, NAME, UNISTRIP.CUS.LEDGER FROM UNISTRIP.ORH, UNISTRIP.CUS WHERE UNISTRIP.CUS.CUSTCODE = UNISTRIP.ORH.CUSTCODE AND UNISTRIP.ORH.LEDGER = '" + Replace(rsOnline__MMColParam, "'", "''") + "' AND UNISTRIP.CUS.LEDGER = '" + Replace(rsOnline__MMColParam, "'", "''") + "' AND STATUS = " + Replace(rsOnline__MMColParam2, "'", "''") + " AND SALESVALUE > '" + Replace(rsOnline__MMColParam3, "'", "''") + "' AND ""DATE"" < #" + Replace(rsOnline__var, "'", "''") + "# ORDER BY ""DATE"", UNISTRIP.ORH.CUSTCODE, IONO"
    rsOnline.CursorType = 0
    rsOnline.CursorLocation = 2
    rsOnline.LockType = 1
    rsOnline.Open()

    rsOnline_numRows = 0
    %>


    The above works except for the DATE < var

    When the code above is run it generates a: -

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
    [Easysoft ODBC]Invalid datetime format
    /unistrip/online.asp, line 52

    I have tried entering the date forwards, backwards and inside out!

    Dates make me :crying:

  2. #2
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Type specifying the date in a YYYY-MM-DD format.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #3
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    I left the code as is except for: -

    <%
    Dim rsOnline__var
    rsOnline__var = "2005-11-01"
    If (Request.QueryString("txtDate") <> "") Then
    rsOnline__var = Request.QueryString("txtDate")
    End If
    %>


    And got this: -

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Easysoft ODBC]Syntax error or access violation "parse error near '#'"
    /unistrip/online.asp, line 52

  4. #4
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Is there anything in the URL for txtDate?
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  5. #5
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    It doesn't matter as it should default to 2005-11-01 but I have tried loading the page with and without it and get the same error

  6. #6
    Join Date
    Feb 2004
    Posts
    4,901
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Quote Originally Posted by s80wkr
    It doesn't matter as it should default to 2005-11-01 but I have tried loading the page with and without it and get the same error
    I know - but what I was saying is that if there WAS something in the URL, it would override the value you are playing with.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  7. #7
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Sorry,

    No I have been leaving txtDate out of the URL

  8. #8
    Join Date
    Jun 2005
    Posts
    1,081
    Thanks
    4
    Thanked 15 Times in 15 Posts

    Default

    You have this in your code currently:

    ""DATE"" < #" + Replace(rsOnline__var, "'", "''") + "#

    Try using this instead:

    ""DATE"" < '" + rsOnline__var + "'

    Also rsOnline_var should be a date in the format Warren suggested ('YYYY-MM-DD')


    I would also, highly suggest you look at using Parameterized queries.

  9. #9
    Join Date
    Jul 2005
    Location
    Surrey
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I use JScript rather than VBScript, so if my comments miss the mark then I apologise. However, this looks similar to a JScript ptoblem I had, so here goes.

    I suspect the your rsOnline_var is undefined. Can you check this ? You said that the URL does not set txtDate. I had a piece of JScript where I expected Request.Querystring to return nothing: instead, it returned undefined, which is not equal to null or an empty string. So the code tests the querystring, finds that is not equal to "" and, in your case, assigns an undefined value to rsOnline_var.

    The solution is to code it as:
    inputDate = IsBlank(Request.Querystring("txtDate"), "")
    if (inputDate <> "") then
    rsOnline_var = inputDate

    At any rate, IsBlank is the function you would use in JScript - don't know if it is the same in VBScript.

    Hope that helps
    John

  10. #10
    Join Date
    Feb 2005
    Posts
    81
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Thanks Sol that worked great!

    Must look into Parameterized queries

    Thanks everyone for your input

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •