Advertisement

03.01.2008 at 03:59PM PST, ID: 23206824 | Points: 400
[x]
Attachment Details

SQL Query in ASP

Asked by Kamil0617 in Active Server Pages (ASP)

Tags:

Just starting some work in ASP for the first time.  Someone chose this language, I didn't.  Have the following.

<%
' First let us create Connection and Recordset objects
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.RecordSet")

' Open the connection to the ODBC source, in this case
' the Access database
Conn.Open "MyDatabase"

' Now, create the SQL statement
GetOrders = "Select distinct tblorder.orderid, shippingmethodid, shippingid from tblOrder, tblorderitem where tblOrder.OrderID=tblorderitem.OrderID AND strorderstatus = 'success' AND intwporderid IS null AND tblorderitem.intitemtypeid = '1' AND tblorderitem.intstatusid= '2' ORDER BY tblOrder.OrderID DESC"

' Execute the SQL statement, and set the recordset object
' to the result of this execution. We obtain the resulting
' records in Rs object
Set Rs = Conn.Execute(GetOrders)

' Use this RecordSet object to populate your HTML output stream
' In this example, we will just write out the last name field
Do While NOT Rs.EOF
  Response.Write(Rs.Fields("OrderID").value)
  response.write(",")
    Response.Write(Rs.Fields("ShippingMethodID").value)
      response.write(",")
      Response.Write(Rs.Fields("shippingID").value)
      response.write(",")
            DIM CurrentShippingID
      CurrentShippingID = Response.Write(Rs.Fields("shippingID").value)
      
response.write(CurrentShippingID)
      
      
GetAddress = "Select * from tblShipping where ShippingID='CurrentShippingID'"
      
      Set Rs2 = Conn.Execute(GetAddress)
      
        Response.Write(Rs2.Fields("ShippingName").value)
      
      
      
      response.write("<br>")
      

      
 ' Move to the next record in the resultset
  Rs.MoveNext
Loop

' Close the Recordset object and destroy it
Rs.Close
Set Rs = Nothing

' You might want to release the resources for connection object,
' unless you want to use the same connection again in the later code
Conn.Close
Set Conn = Nothing
%>

Basically loopoing through orders, and want to display the orderID, ShippingMethodID, ShippingID, and then want to use the ShippingID, to query tblShipping to get the name and display that as well.  But it is not working.  Any idea what is wrong?Start Free Trial
[+][-]03.01.2008 at 09:35PM PST, ID: 21025084

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 06:45AM PST, ID: 21026114

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 06:58AM PST, ID: 21026138

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 07:05AM PST, ID: 21026163

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 07:09AM PST, ID: 21026170

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 07:49AM PST, ID: 21026375

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 08:30AM PST, ID: 21026533

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 08:54AM PST, ID: 21026605

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 08:58AM PST, ID: 21026620

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 10:48AM PST, ID: 21026979

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 11:19AM PST, ID: 21027105

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 11:41AM PST, ID: 21027187

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 01:20PM PST, ID: 21027637

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 02:33PM PST, ID: 21027955

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.02.2008 at 04:31PM PST, ID: 21028334

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 10:38AM PST, ID: 21034318

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 10:45AM PST, ID: 21034377

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 10:50AM PST, ID: 21034418

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 10:55AM PST, ID: 21034460

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 10:56AM PST, ID: 21034477

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 11:05AM PST, ID: 21034552

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 11:06AM PST, ID: 21034567

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 11:09AM PST, ID: 21034587

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 11:16AM PST, ID: 21034673

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 11:25AM PST, ID: 21034766

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 01:01PM PST, ID: 21035603

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.03.2008 at 01:03PM PST, ID: 21035629

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628