Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2005, 11:53 AM
Authorized User
 
Join Date: Dec 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL problem in ASP

I have an ASP form with two date fields (FromDate and ToDate).

I get this error.

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression 'dtDate >= #1# and dtDate <=#1#'.
/Fast2/WkTotalOrders.asp, line 27

Here's the code for my results page.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("FromDate") <> "") Then
  Recordset1__MMColParam = Request.QueryString("FromDate")
End If
%>
<%
Dim Recordset1__MMColParam2
Recordset1__MMColParam2 = "1"
If (Request.QueryString("ToDate") <> "") Then
  Recordset1__MMColParam2 = Request.QueryString("ToDate")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_Fast2_STRING
Recordset1.Source = "SELECT * FROM qryDailyOrderTotals WHERE dtDate >= #" + Replace(Recordset1__MMColParam, "#", "##") + "# and dtDate <=#" + Replace(Recordset1__MMColParam2, "#", "##") + "#"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Recordset2__MMColParam
Recordset2__MMColParam = "1"
If (Request.QueryString("FromDate") <> "") Then
  Recordset2__MMColParam = Request.QueryString("FromDate")
End If
%>
<%
Dim Recordset2__MMColParam2
Recordset2__MMColParam2 = "1"
If (Request.QueryString("ToDate") <> "") Then
  Recordset2__MMColParam2 = Request.QueryString("ToDate")
End If
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_Fast2_STRING
Recordset2.Source = "SELECT * FROM qryDailyPartTotals WHERE dtDate >= #" + Replace(Recordset2__MMColParam, "#", "##") + "# and dtDate <= #" + Replace(Recordset2__MMColParam2, "#", "#") + "#"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
%>
<%
Dim Recordset3__MMColParam
Recordset3__MMColParam = "1"
If (Request.QueryString("FromDate") <> "") Then
  Recordset3__MMColParam = Request.QueryString("FromDate")
End If
%>
<%
Dim Recordset3__MMColParam2
Recordset3__MMColParam2 = "1"
If (Request.QueryString("ToDate") <> "") Then
  Recordset3__MMColParam2 = Request.QueryString("ToDate")
End If
%>
<%
Dim Recordset3
Dim Recordset3_numRows

Set Recordset3 = Server.CreateObject("ADODB.Recordset")
Recordset3.ActiveConnection = MM_Fast2_STRING
Recordset3.Source = "SELECT * FROM qryDailyTimeTotals WHERE dtDate >= #" + Replace(Recordset3__MMColParam, "#", "##") + "# and dtDate<=#" + Replace(Recordset3__MMColParam2, "#", "##") + "#"
Recordset3.CursorType = 0
Recordset3.CursorLocation = 2
Recordset3.LockType = 1
Recordset3.Open()

Recordset3_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = -1
Repeat2__index = 0
Recordset2_numRows = Recordset2_numRows + Repeat2__numRows
%>
<%
Dim Repeat3__numRows
Dim Repeat3__index

Repeat3__numRows = -1
Repeat3__index = 0
Recordset3_numRows = Recordset3_numRows + Repeat3__numRows
%>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
function DoDateTime(str, nNamedFormat, nLCID)
    dim strRet
    dim nOldLCID

    strRet = str
    If (nLCID > -1) Then
        oldLCID = Session.LCID
    End If

    On Error Resume Next

    If (nLCID > -1) Then
        Session.LCID = nLCID
    End If

    If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
        strRet = FormatDateTime(str, nNamedFormat)
    End If

    If (nLCID > -1) Then
        Session.LCID = oldLCID
    End If

    DoDateTime = strRet
End Function
</SCRIPT>
<html>
<head>
<title>Weekly Totals</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">
<p align="center"><strong>Fast Incoming Order Totals</strong></p>
<p align="center"><%=(Recordset1.Fields.Item("dtDate" ).Value)%></p>
<table width="700" border="0" align="center" bgcolor="#FFFFFF">
  <tr bgcolor="#FFCC00" >
    <td width="14" height="21" bgcolor="#FFFFFF">
      <div align="center"></div></td>
    <td width="286" bgcolor="#FFFFFF">
      <div align="center"></div></td>
    <td width="174" bgcolor="#FFFFFF">
      <div align="center"><strong>Orders</strong></div></td>
    <td width="176" bgcolor="#FFFFFF">
      <div align="center"></div>
      <div align="center"></div>
      <div align="center"><strong>Parts </strong></div></td>
    <td width="6" bgcolor="#FFFFFF">&nbsp;</td>
    <td width="165" bgcolor="#FFFFFF">
      <div align="center"></div>
      <div align="center"></div>
      <div align="center"><strong>Time </strong></div></td>
    <td width="47" bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr >
    <td height="20" colspan="3" bgcolor="#FFFFFF">
      <table width="370" border="1">
        <% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %>
        <tr bgcolor="#FFFFFF" >
          <td width="160" height="20">
            <strong><%=(Recordset1.Fields.Item("CatType").Valu e)%></strong><div align="center">
            </strong></div></td>
          <td width="100">
            <div align="center"><strong></strong></div>
            </td>
          <td width="160" height="20"><strong><%=(Recordset1.Fields.Item("Em pName").Value)%></strong></td>
          <td width="50" height="20">
            <div align="center"><%=(Recordset1.Fields.Item("CountOf Part").Value)%></div></td>
        </tr>
        <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
      </table></td>
    <td height="25" colspan="2" bgcolor="#FFFFFF">
      <table width="105" border="1" cellpadding="1" cellspacing="2" bgcolor="#FFFFFF">
        <% While ((Repeat2__numRows <> 0) AND (NOT Recordset2.EOF)) %>
        <tr>
          <td height="20" bgcolor="#FFFFFF">
            <div align="center"></div>
            <div align="center"></div>
            <div align="center"></div>
            <div align="center"><%=(Recordset2.Fields.Item("SumOfPa rt").Value)%></div></td>
        </tr>
        <%
  Repeat2__index=Repeat2__index+1
  Repeat2__numRows=Repeat2__numRows-1
  Recordset2.MoveNext()
Wend
%>
      </table></td>
    <td height="20" colspan="2" bgcolor="#FFFFFF">
      <table width="105" border="1">
        <% While ((Repeat3__numRows <> 0) AND (NOT Recordset3.EOF)) %>
        <tr>
          <td height="20" bgcolor="#FFFFFF">
            <div align="center"></div>
            <div align="center"></div>
            <div align="center"></div>
            <div align="center"><%= DoDateTime((Recordset3.Fields.Item("SumOfTimeDiff" ).Value), 3, 2057) %></div>
            <div align="center"></div></td>
        </tr>
        <%
  Repeat3__index=Repeat3__index+1
  Repeat3__numRows=Repeat3__numRows-1
  Recordset3.MoveNext()
Wend
%>
      </table></td>
  </tr>
</table>
<p align="center"><strong></strong></p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
<%
Recordset3.Close()
Set Recordset3 = Nothing
%>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird ASP/SQL Problem cancer10 Classic ASP Databases 4 March 7th, 2007 09:15 AM
ASP/SQL Problem cancer10 Classic ASP Databases 9 February 28th, 2007 11:17 AM
Tricky asp/sql problem cedwards Dreamweaver (all versions) 8 June 13th, 2005 04:02 PM
Need help with ASP SQL Date problem bleutiger Classic ASP Professional 6 January 21st, 2005 12:41 AM
ASP SQL Date Problem Please help bleutiger Classic ASP Databases 5 January 20th, 2005 05:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.