ASP.NET
  Home arrow ASP.NET arrow Page 10 - What is ADO?
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 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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? 
ASP.NET

What is ADO?
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 16
    2004-08-11

    Table of Contents:
  • What is ADO?
  • About Universal Data Access
  • Existing Technologies
  • Why ADO?
  • ADO and ADO.NET
  • Providers and Drivers
  • New Features
  • ADO 2.8
  • Examples 1-3
  • Examples 4-6
  • Language Differences
  • Creating Objects in JScript, Visual C and .NET

  • 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


    What is ADO? - Examples 4-6


    (Page 10 of 12 )

     

    Example 4

    This example uses the Fields collection of the recordset to loop through all of the fields in a recordset, then prints the details in the debug window:

    ' Declare the object variables
    Dim objRs As ADODB.Recordset
    Dim objFld As ADODB.Field
    Set pbjRs = New ADODB.Recordset

    ' Open a recordset on the 'authors' table using the
    ' OLE DB Driver for ODBC
    ' without using a connection
    objRs.Open "authors", "DSN=pubs", _
             adOpenForwardOnly, adLockReadOnly, adCmdTable

    ' Loop through the Fields collection printing the
    ' name of each Field
    ' The Fields collection is discussed in Chapter 6
    For Each objFld In objRs.Fields
         Debug.Print objFld.Name; vbTab;
    Next
    Debug.Print

    ' Loop through the records in the recordset
    While Not objRs.EOF
         ' Loop through the fields, this time printing out
         ' the value of each field
         For Each objFld In objRs.Fields
              Debug.Print objFld.Value; vbTab;
         Next Debug.Print
         objRs.MoveNext
    Wend

    ' Close the recordset and release the memory
    objRs.Close
    Set objRs = Nothing
    Set objFld = Nothing

    Example 5

    This is an ADOX example; it uses a Catalog and its associated Tables collection to list the tables in a data store:

    ' Declare the object variables
    Dim objCat    As ADOX.Catalog
    Dim objTable As ADOX.Table
    Dim strConn  As String
    Set objCat = New ADOX.Catalog

    ' set the connection string
    strConn="Provider=Microsoft.Jet.OLE DB.4.0; Data Source= _
                 C:\temp\pubs.mdb"

    ' point the catalog at a data store
    objCat.ActiveConnection = strConn

    ' loop through the tables collection
    For Each objTable In objCat.Tables
         Debug.Print objTable.Name
    Next

    ' clean up
    Set objTable = Nothing
    Set objCat = Nothing

    Example 6

    This example also shows ADOX, and uses a Catalog, its Tables collection, and the Indexes and Columns collections for a table to print a list of columns for the index:

    Dim objCat       As ADOX.Catalog
    Dim objTbl       As ADOX.Table
    Dim objIdx       As ADOX.Index
    Dim objCol       As ADOX.Column
    Dim strConn     As String
    Set objCat = New ADOX.Catalog

    ' set the connection string
    strConn="Provider=Microsoft.Jet.OLE DB.4.0; Data Source= _
                 C:\temp\pubs.mdb"

    ' point the catalog at a data store
    objCat.ActiveConnection = strConn

    ' loop through the tables
    For Each objTbl In objCat.Tables
         ' has the table got indexes
         If objTbl.Indexes.Count > 0 Then
              Debug.Print objTbl.Name
         ' loop through the indexes
         For Each objIdx In objTbl.Indexes
                   Debug.Print vbTab; objIdx.Name; vbTab;
                              objIdx.PrimaryKey
                   'loop through the columns in the index
                   For Each objCol In objIdx.Columns
                        Debug.Print vbTab; vbTab; objCol.Name
                   Next 
              Next
         End If
    Next

    ' clean up
    Set objCol = Nothing
    Set objTbl = Nothing
    Set objIdx = Nothing
    Set objCat = Nothing

    This is from ADO Programmer's Reference, by Dave Sussman (Apress, ISBN 1590593421). Check it out at your favorite bookstore today. Buy this book now.

    More ASP.NET Articles
    More By Apress Publishing


     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT