<%@ Language=VBScript %> <html> <head> <!--MAY GOD ALMIGHTY INCREASE MY KNOWLEDGE FOR WELLBEING OF MANKIND--> <!--Original: Syed Armoghan Qadir Shah (Armoshah@hotmail.com)--> <!-- This vbScript Source!! http://www.sei-incentives.com--> <!--Email your questions to Syed at Armoshah@hotmail.com--> <meta NAME="GENERATOR" Content="Microsoft FrontPage 4.0"> <title></title> </head> <body> <h2 align="center"> Northwind Orders </h2> <p align="center">Please click on OrderID to get Order Details or. <br> Search on Shipper Name.</p> <p align="center"> <script LANGUAGE="vbscript" RUNAT="Server"> '--Declare all the variables Dim cn, rsOrders, rsEmployees Dim strConnect, strSQL, intCounter Dim strFieldValue, strFieldName Dim strHREF, strEmpFName, strEmpLastName Dim intEmpID Dim SearchText '--Input for Search on Shipper Name SearchText = Request.Form("txtSearchText") '--Create Objects Set cn = Server.CreateObject("ADODB.Connection") '--Ensure that you have created Data Source Name for the database strConnect = "DSN=Northwind" Call cn.Open(strConnect) '--Create Recordsets Set rsOrders = Server.CreateObject("ADODB.Recordset") strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY orderDate DESC;" '-- Sort Date SQL If Request.Form("btnsortdate") = "A-Z" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY OrderDate ASC;" end if If Request.Form("btnsortdate") = "Z-A" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY OrderDate DESC;" end if '-- Sort OrderID SQL If Request.Form("btnsortOID") = "A-Z" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY OrderID ASC;" end if If Request.Form("btnsortdate") = "Z-A" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY OrderID DESC;" end if '-- Sort CustomerID SQL If Request.Form("btnsortUID") = "A-Z" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY CustomerID ASC;" end if If Request.Form("btnsortUID") = "Z-A" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY CustomerID DESC;" end if '-- Sort ShipName SQL If Request.Form("btnsortFN") = "A-Z" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY ShipName ASC;" end if If Request.Form("btnsortFN") = "Z-A" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM orders ORDER BY ShipName DESC;" end if '-- Search SQL If Request.Form("btnSearch") = "Search" Then strSQL = "SELECT OrderID, CustomerID, OrderDate, ShipName FROM [Orders]" & _ "WHERE ShipName LIKE '" & SearchText & "%';" End If '--Open Orders recordset Call rsOrders.Open(strSQL, cn, 0, 1) '--Write out data in tables via the submit forms Call Response.Write("<form action=""Master.asp"" method=""post"">") Call Response.Write("<p align=center>") Call Response.Write("<input type=""text"" name=""txtSearchText"" size=""30"">" & "<input type=""submit"" name=""btnSearch"" value=""Search"">") Call Response.Write("</p>") Call Response.Write("<Table border = 3 cellpadding=2 cellspacing=2>") Call Response.Write("<TD width=0 bgcolor=#800000>" & "<B><I><font color=#ffffff>Orders</I></B>" & "</td>") Call Response.Write("<Tr>") '--Write out custom headings Call Response.Write("<TH>" & "<B>Order ID</B>" & "</TH>") Call Response.Write("<TH>" & "<B>Customer ID</B>" & "</TH>") Call Response.Write("<TH>" & "<B>Order Date</B>" & "</TH>") Call Response.Write("<TH>" & "<B>Shipper Name</B>" & "</TH>") Call Response.Write("</Tr>") '--Write out Ascending and Descending Buttons Call Response.Write("<TR>") Call Response.Write("<Td align=center>" & "<input type=submit name=btnsortOID value=A-Z>" & "<input type=submit name=btnsortOID value=Z-A>" &"</td>") Call Response.Write("<Td align=center>" & "<input type=submit name=btnsortUID value=A-Z>" & "<input type=submit name=btnsortUID value=Z-A>" &"</td>") Call Response.Write("<Td align=center>" & "<input type=submit name=btnsortdate value=A-Z>" & "<input type=submit name=btnsortdate value=Z-A>" &"</td>") Call Response.Write("<Td align=center>" & "<input type=submit name=btnsortFN value=A-Z>" & "<input type=submit name=btnsortFN value=Z-A>" &"</td>") Call Response.Write("</TR>") While(rsOrders.EOF = False) Call Response.Write("<Tr>") for intCounter = 0 to rsOrders.Fields.Count - 1 'Write out field data. Call Response.Write("<TD width=10%>") strFieldName = rsOrders.Fields(intCounter).Name strFieldValue = rsOrders.Fields(intCounter).Value If(strFieldName = "OrderID")Then '--This is the key (Master) field. '--We will want to make this field a link to the detail field '--We will create a URL and append the key to the URL in order '--to retrieve it on the Detail page using the '--Request.QueryString() method. '--Please Put your hosting address after the http. 'strHREF = "<A HREF=""" & "http://YOUR DOMAIN NAME/Detail.asp?strID=" & strFieldValue & """>" & strFieldValue & "</A>" strHREF = "<A HREF=""" & "http://www.sei-incentives.com/atest/Detail.asp?strID=" & strFieldValue & """>" & strFieldValue & "</A>" Call Response.Write(strHREF) ElseIf(IsNull(strFieldValue))Then '--The field is empty, just write out an HTML space. call Response.Write("&nbsp;") Else Call Response.Write(strFieldValue) End If Call Response.Write("</TD>") next Call Response.Write("<Tr>") rsOrders.MoveNext Wend Response.Write("</Table>") Response.Write("</Form>") Set rsOrders = Nothing Set cn = Nothing Call Response.Write("</form>") </script> </body> </html>