Databases Reference
In-Depth Information
Debug.Print "Source: " & rs.Source
rs.Close
' ---------------------------------------
' Use Command object
' Always a read-only, forward only cursor
' ---------------------------------------
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cn
cmd.CommandText = "SELECT * FROM Names"
Set rs = cmd.Execute
rs.MoveFirst
Debug.Print
Debug.Print "Use Command object: "
Debug.Print "ActiveConnection: " & rs.ActiveConnection
Debug.Print "Source: " & rs.Source
rs.Close
cn.Close
End Sub
For future reference, let us note the output from the Debug.Print statements in Example
17-1. In each case, the ActiveConnection property of the recordset is the same. I have
broken the string into multiple lines to aid readability:
Provider=Microsoft.Jet.OLEDB.3.51;
Persist Security Info=False;
User ID=Admin;
Data Source=D:\BkAccessII\AccessCode.mdb;
Mode=Share Deny None;
Extended Properties=";
COUNTRY=0;
CP=1252;
LANGID=0x0409";
Locale Identifier=1033;
Jet OLEDB:System database="";
Jet OLEDB:Registry Path="";
Jet OLEDB:Database Password="";
Jet OLEDB:Global Partial Bulk Ops=2
As we will see when we discuss connection strings in more detail later in the chapter, this
after-the-fact approach is one of the best (read: only ) ways to actually see what a
complete connection string looks like.
As for the Source property, here is the output:
Use rs.Open with table:
Source: select * from Names
Use cn.Execute:
Source: SELECT * FROM Names
Search WWH ::




Custom Search