Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 August 2nd, 2003, 02:10 PM
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with objRS.Open syntax

Hi All, I'm joining the Orders and Order Details tables in Northwind
DB. I'm not sure of the syntax for the objRS.Open statement. I'm getting compilation errors from everything I use in the statement eg)
new_sql, "Orders", anybody have any ideas how to format it? Here's my code. Thanks all.

  <% @LANGUAGE = VBScript %>
  <% Option Explicit
  Response.Expires = 0


  Dim objConn, objRS, strConnection, new_sql
  Set objConn = Server.CreateObject("ADODB.Connection")
  strConnection = "DSN=Nwind;Database=Nwind;"
  strConnection = strConnection & "User ID=sa;Password=;"
  objConn.Open strConnection
  Set objRS = Server.CreateObject("ADODB.Recordset")
  Set objRS.ActiveConnection = ObjConn

  new_sql = "SELECT Orders.CustomerID AS CustomerName, [Quantity] * [UnitPrice] AS OrderAmount, [Order Details].ProductID AS ProductOrdered, Orders.EmployeeID AS SalesPerson, Orders.Freight AS FreightCost, [Order Amount] * [1-(Discount/100)] + [Freight] AS TotalCost "
  response.write new_sql
  new_sql = new_sql & "FROM Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID"
  objRS.Open new_sql


  %>
  <HTML>
  <HEAD>
  <TITLE>Order Information Table</TITLE>
  </HEAD>
  <BODY bgcolor="#FFCCFF">
  <Table Width = 80%><TD Width = 80% >
  <TABLE border=1 bgcolor=#FFFFFF bordercolor= #000033>
  <H1 ALIGN=CENTER></H1>
  <CellPadding=0 CellSpacing=0>

   <TR>

       <TH NOWRAP>Customer Name</TH>
       <TH NOWRAP>Product Ordered</TH>
       <TH NOWRAP>Sales Person</TH>
       <TH NOWRAP>Order Amount</TH>
       <TH NOWRAP>Freight Cost</TH>
       <TH NOWRAP>Total Cost</TH>
       </TR>

  <% Do While Not objRS.EOF %>

       <TR>

       <TD><%=objRS("CustomerID")%></TD>
       <TD><%=objRS("ProductID")%></TD>
       <TD><%=objRS("EmployeeID")%></TD>
       <TD><%=objRS("Quantity")%></TD>
       <TD><%=objRS("UnitPrice")%></TD>
       <TD><%=objRS("Freight")%></TD>

       </TR>

       <%
          objRS.MoveNext

         Loop

        %>
  </TABLE>
  </BODY>
  </HTML>

  <%
  objRS.close
  objConn.close:
  Set objRS = Nothing
  Set objConn = Nothing
  %>



 
Old August 5th, 2003, 09:17 PM
Registered User
 
Join Date: Jul 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tcasp
Default

try the following ;

Set Conn = Server.createobject("Adodb.connection")
            Set RS = Server.CreateObject ("ADODB.Recordset")
            Conn.Open "test"






Similar Threads
Thread Thread Starter Forum Replies Last Post
Random record from objRS - why is EOF or BOF True? jfrizelle Classic ASP Databases 0 February 5th, 2008 07:24 AM
problem with syntax MarkMingLuy ASP.NET 1.0 and 1.1 Basics 1 November 30th, 2006 07:42 AM
Syntax Problem Please i need your help haron_Master VB Databases Basics 4 February 2nd, 2005 01:56 PM
objRS.Filter (Multiple Field Filters) egerdj Classic ASP Basics 1 March 10th, 2004 04:48 PM
objRS.MoveLast pab006 Classic ASP Basics 1 February 25th, 2004 10:52 AM





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