BrainDump
  Home arrow BrainDump arrow ADO Queries and Working with Recordsets
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

ADO Queries and Working with Recordsets
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2008-01-14

    Table of Contents:
  • ADO Queries and Working with Recordsets
  • Displaying Selected Records Using a Drop Down Menu
  • Sorting Records
  • How to Add a Record to Table
  • How To Delete a Record

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    ADO Queries and Working with Recordsets
    (Page 1 of 5 )

    Back in late November of last year I wrote an article that covered ADO for the beginner. At that time I left off with ADO connections, recordsets, and how to display them. Finally returning to the topic after a spell, in this episode we will discuss queries, sorting, and a few other tricks with ADO.

     If you'd like to review before we proceed, you can read the previous tutorial. Go ahead, I'll wait. Or if you want a quicker review, we'll pick up at the very end of it, where I showed you the Victims table from the chucknorrisvictims database:

     

    VictimName

    VictimInjury

    HowItHappened

    Ralph Macchio

    Broken Foot

    Ralph Macchio tried his crane kick on Chuck. When it connected to Chuck's powerful chest hairs, his foot shattered.

    Jackie Chan

    Forced to work with Chris Tucker the rest of his life

    Chuck Norris punched Jackie Chan so hard he went from an A-list actor to a B-list actor

    Death

    Granted Eternal Life

    Death came for one of Chuck's victims before he was finished with him, so Chuck did a roundhouse kick and hit Death so hard not only did he become a living being, but he gained immortality as well.

    Displaying Selected Records

    We can use SQL to create queries in ADO when we want to see data that matches a certain criteria. Let’s say we are working with our chucknorrisvictims database and we want to extract everyone whose name begins with “J”:


    <html>

    <body>

    <%

    set conn=Server.CreateObject("ADODB.Connection")

    conn.Provider="Microsoft.Jet.OLEDB.4.0"

    conn.Open "c:/webdata/chucknorrisvictims.mdb"

    set rs=Server.CreateObject("ADODB.recordset")

    sql="SELECT VictimName, VictimInjury FROM Victims

    WHERE VictimName LIKE 'J%'"

    rs.Open sql, conn

    %>

    <table border="1" width="100%">

    <tr>

    <%for each x in rs.Fields

    response.write("<th>" & x.name & "</th>")

    next%>

    </tr>

    <%do until rs.EOF%>

    <tr>

    <%for each x in rs.Fields%>

    <td><%Response.Write(x.value)%></td>

    <%next

    rs.MoveNext%>

    </tr>

    <%loop

    rs.close

    conn.close%>

    </table>

    </body>

    </html>

    This would result in the following:

     

    VictimName

    VictimInjury

    Jackie Chan

    Forced to work with Chris Tucker the rest of his life

    More BrainDump Articles
    More By James Payne


       · Welcome to my article on ADO Queries. Prepare to have your puny mind blown as you...
       · Hi James, I'd like to see an article dealing with how to import attribute-centric...
     

    BRAINDUMP ARTICLES

    - Handling Multiple Contracts with Indigo
    - Cleaning Out Your Data in XP
    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway