Microsoft Access
  Home arrow Microsoft Access arrow Page 4 - Exploring Multiple Active Record Sets with...
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 
Moblin 
JMSL Numerical Library 
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? 
MICROSOFT ACCESS

Exploring Multiple Active Record Sets with MS Access
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 6
    2006-05-31

    Table of Contents:
  • Exploring Multiple Active Record Sets with MS Access
  • Connecting to SQL 2005 using ADO
  • Executing SQL Queries on the Open Connection
  • Interleaving Data from Two Recordsets

  • 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


    Exploring Multiple Active Record Sets with MS Access - Interleaving Data from Two Recordsets


    (Page 4 of 4 )

    The values from the recordsets can be interleaved as the following example shows. Of course the example is trivial, and contrived to display one row of data from one recordset followed by several related rows of data from another recordset -- in the nature of a join (see the last picture in this article). This is indeed useful if joins are not possible for some reason, or they are costly. Since Select, Bulk Insert, Fetch and a few other operations are possible, and as the recordsets are open, it will be possible to see the updated values without closing the connection.

    
    Private Sub Form_Load()
    Dim con As New ADODB.Connection
    con.ConnectionString = "Provider=SQLNCLI;" _
    & "Server=HODENTEKMYSORIAN;" _
    & "Database=Northwind;" _
    & "Integrated Security=SSPI;" _
    & "DataTypeCompatibility=80;" _
    & "MARS Connection=True;"
    con.Open
    Dim recordsaffected As Integer
    Dim str1
    Dim str2
    str1 = "SELECT ProductID, ProductName from Products where
    (ProductID)='17'"
    str2 = "SELECT OrderID, ProductID, UnitPrice, Quantity FROM
    [Order Details] WHERE (ProductID = '17')"
    Set rst1 = con.Execute(str1, recordsaffected, adCmdText)
    Set rst2 = con.Execute(str2, recordsaffected, adCmdText)
    Dim strRst1
    strRst1 = ""
    rst1.MoveFirst
    While Not rst1.EOF
    If rst1.Fields.Item(0).Value = "17" Then
    strRst1 = strRst1 & rst1.Fields.Item(0).Value & " | " 
    & rst1.Fields.Item(1).Value & ";" Else strRst1 = strRst1 + "" End If rst1.MoveNext Wend MsgBox ("First RST is: " & strRst1) Dim str3 str3 = "" While Not rst2.EOF str3 = str3 & ";" & rst2.Fields.Item(0).Value & " | "
    & rst2.Fields.Item(1).Value & " | " & rst2.Fields.Item(2).Value & ";" rst2.MoveNext Wend MsgBox ("Second Rst is: " & str3) Dim strln strln = "**************************************" Me.List0.RowSource = strRst1 & strln & vbCrLf & str3 con.Close Set con = Nothing End Sub
     

    The result of displaying the form is shown in the next picture.

    Summary

    The tutorial has presented some of the basic features of connecting to SQL Server 2005 from MS Access using ADO. Some of the properties of the multiple record sets activated have been explored. Since the data is accessed by the fastest cursor combined with multiple cursors open at the same time (but not operating in parallel), it should be possible to improve the performance of data retrieval in the sense of fast access. Various limitations and other important considerations are outside the scope of this basic article and the reader is recommended to look in MSDN sites and dedicated blogs.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Multiple Active Record Sets is new in SQL 2005 server. Although presented as a MS...
     

    MICROSOFT ACCESS ARTICLES

    - Linking SQL Express 2005 Tables to MS Access...
    - Working with Access Projects in Access 2007
    - Exploring Access 2007
    - Working with Stored Procedures in an MS Acce...
    - Creating and Using Action Queries
    - Creating Data Access Pages with Charts using...
    - Advanced Ideas using VBA
    - VBA Details
    - Updating Records in MS Access
    - Using ADO`s Record Object with URLs
    - Exporting XML from MS Access 2003
    - Importing XML into MS Access 2003
    - On Using Pass-through Queries in MS Access
    - Distributed Queries in MS Access
    - Configuring a Linked Microsoft Access Server...





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