Wrox Programmer Forums
|
ASP E-commerce As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP E-commerce 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 January 19th, 2004, 05:22 AM
Registered User
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Work well with Access but not SQL

I download the code from the Beginning Active Server Pages 3.0 and the BrowseListing.asp in chapter 12 code can't work with SQL Server.Why?


<BASEFONT FACE="Comic Sans MS" COLOR="DarkBlue">
<HTML>
<HEAD>
<TITLE>Wrox Classifieds</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFF80">
<CENTER><H1>Wrox Classifieds<BR>Items for sale</H1>
<%
  If Session("PersonID") <> "" Then
    Response.Write "<H3>Welcome " & Session("GivenName") & "</H3>"
  End If
%>
</CENTER>
<P>Here's a list of all the items that our users have made available for purchase:
</P>
<%
  Dim rsItems
  strSQL = "SELECT * FROM Item " & _
           "WHERE ExpirationDate > #" & FormatDateTime(Now,2) & "# " & _
           "AND ItemStatus = 'Active';"
  Set rsItems = Server.CreateObject("ADODB.Recordset")
  rsItems.Open strSQL, objConn
  If Not rsItems.EOF Then
    Response.Write _
      "<TABLE BORDER=""1"" CELLSPACING=""3"" CELLPADDING=""3"">" & _
      " <TR>" & _
      " <TH>Item ID"
               If Session("PersonID") <> "" Then
                 Response.Write "<BR>Click to Bid"
               End If
           Response.Write "</TH>" & _
      " <TH>Name</TH>" & _
      " <TH>Asking Price</TH>" & _
      " <TH>Listing Date</TH>" & _
      " <TH>Current Bid</TH>" & _
      " <TH>Bid Time</TH>" & _
      " </TR>"
    Do While Not rsItems.EOF
      Response.Write "<TR ALIGN=CENTER>"
      If Session("PersonID") <> "" Then
        Response.Write _
          "<TD><A HREF=""Bid.asp?Item=" & rsItems("ItemID") & """>" & _
          rsItems("ItemID") & "</A></TD>"
      Else
        Response.Write "<TD>" & rsItems("ItemID") & "</TD>"
      End If
      Response.Write _
        "<TD>" & rsItems("ItemName") & "</TD>" & _
        "<TD>" & FormatCurrency(rsItems("AskingPrice")) & "</TD>" & _
        "<TD>" & FormatDateTime(rsItems("ListingDate"),2) & "</TD>" & _
      "</TR>"
      rsItems.MoveNext
    Loop
    Response.Write "</TABLE>"
    rsItems.close
    Set rsItems = Nothing
  Else
    Response.Write "<CENTER><H2>No items currently for sale</H2></CENTER>"
  End If
%>
<P>

<TABLE BORDER=0 WIDTH=100%>
  <TR ALIGN=CENTER>
    <% If Session("PersonID") <> "" Then %>
      <TD WIDTH=33%>Browse the listings</TD>
      <TD WIDTH=33%><A HREF="ViewMySaleItems.asp">List/Edit Sale Items</a></TD>
      <TD WIDTH=33%><A HREF="Register.asp?Update=True">
                    Edit Registration Info</A></TD>
    <% Else %>
      <TD WIDTH=33%>Browse the listings</TD>
      <TD WIDTH=33%><A HREF="Login.asp">Login</A></TD>
      <TD WIDTH=33%><A HREF="Register.asp">I'm a new user</A></TD>
    <% End If %>
  </TR>
</TABLE>
</BODY>
</HTML>
 
Old January 19th, 2004, 07:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

on this line
 strSQL = "SELECT * FROM Item " & _
           "WHERE ExpirationDate > #" & FormatDateTime(Now,2) & "# " & _
           "AND ItemStatus = 'Active';"
change # to ' (# is specific to Access, SQL Server uses ' for dates)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Wizards Won't work am11 Access 17 November 8th, 2007 10:09 AM
Access combo box does not work with SQL Server jerryk Access 3 July 14th, 2006 03:30 PM
htmlInput control doesn't work with Access file? huilyu HTML Code Clinic 0 October 16th, 2003 06:12 PM
not work in sql query like '%[%' vincentc SQL Server 2000 2 October 9th, 2003 03:34 AM





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