Microsoft Access
  Home arrow Microsoft Access arrow Page 2 - 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 
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? 
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 - Connecting to SQL 2005 using ADO


    (Page 2 of 4 )

    Create a blank MS Access application. Since it is a blank application there are as yet no objects in this database. Create a new form from design and save it with the name Martian. To the load event of the form add the code shown here. The recordsets are assigned by the connection's execute method, and are available for reviewing.

    
    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
    Set rst1 = con.Execute("SELECT OrderDate, OrderID FROM Orders where
    OrderDate>'5/5/1998'", recordsaffected, adCmdText)
    Set rst2 = con.Execute("SELECT ProductID, ProductName, UnitPrice
    FROM Products", recordsaffected, adCmdText)
    Set rst3 = con.Execute("SELECT UnitPrice, OrderID From [Order Details]",
    recordsaffected, adCmdText)
    Set rst1 = con.Execute("SELECT OrderDate,OrderID FROM Orders where
    OrderDate>'5/5/1998'", recordsaffected, adCmdText)
    '------Place code from next section to populate a list box-----
    '--------------------------------------------------------------
    MsgBox ("Number of Columns in the rst1 recordset is = " &
    rst1.Fields.Count)
    MsgBox ("Number of Columns in the rst2 recordset is = " &
    rst2.Fields.Count)
    MsgBox ("Number of Columns in the rst3 recordset is = " &
    rst3.Fields.Count)
    con.Close
    Set con = Nothing End Sub
    
    Connection String

    The SQLNC connection string has several components to it. The provider now is called SQLNCI, short for SQL Native client, the new API alluded to in the introduction. The server is the SQL 2005 server (the instance name is Mysorian) on the machine Hodentek. The database is Northwind as described earlier. The security is Windows integrated and the DataType Compatibility is set to 80; this is necessary so that the ADO data types map correctly to the new data types of the SQLNCI. Of course if you want to access Multiple Active Recordsets (MARS), you want this argument (MARS Connection) to be assigned a value true.

    After providing this string you may open the connection, and this connection will support opening multiple record sets at the same time. The results from these can be used independently, or in any other fashion within the context of a single batch.

    More Microsoft Access Articles
    More By Jayaram Krishnaswamy


       · 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 4 hosted by Hostway
    Stay green...Green IT