Listing 6: Accessing Data Without Connection and Command Objects ' Declare connection string variable Dim csSqlServer ' Declare command text variable Dim ctContacts ' Declare recordset variable Dim rsContacts ' Declare argument constants Const adPersistXML = 1 Const adStateOpen = 1 ' Define connection string csSqlServer = "Provider='sqloledb';Data Source='ws04';" & _ "Integrated Security='SSPI';Initial Catalog='AdventureWorks';" ' Define the command text ctContacts = "SELECT TOP 10 FirstName, LastName FROM Person.Contact" ' Create and populate recordset object Set rsContacts = CreateObject("ADODB.Recordset") rsContacts.Open ctContacts, csSqlServer ' Save data to XML file rsContacts.Save "C:\Info\SqlServerContacts.xml", adPersistXML ' Clean up If rsContacts.State = adStateOpen then rsContacts.Close End If Set csSqlServer = Nothing Set ctContacts = Nothing Set rsContacts = Nothing