Employee.ManagerID" ??
& " FROM HumanResources.Employee)));"
DoClearSheet
GetData sConnString, sSQL
m_cXL.DoAutoFit
Set m_cData = Nothing
Set m_cXL = Nothing
End Sub
I mentioned a moment ago that neither of our helper methods made any direct VBA calls.
The same is true of the GetManagers method. All of our work is being done by our objects from
start to finish. The beauty of this is that we can drop these classes in any Excel project and
have this functionality available instantly.
In our current Excel project, we can change the database and/or SQL statement and
import any data we need via the cData object.
Summary
In this chapter, you??™ve taken a look at some of the many data access methods you can use in
Excel. You??™ve seen how to use DAO to get data into an Excel workbook. DAO, while old technology,
is certainly still a viable alternative for Windows 2000 or XP users. It??™s easy to use and very
fast if you??™re working with local data sources like an Access database stored on your hard drive.
But what if you need to work with remote data? Or what if you need to work with data in a disconnected
fashion? In the next section, we began using ActiveX Data Objects (ADO), a
technology that addresses these issues and more.
CHAPTER 2 n DATA IN, DATA OUT 96
You??™ve also explored various methods of importing data into your Excel workbooks.
You??™ve pulled data from Access databases to text files to ODBC and OLE DB data sources.
You??™ve also taken a look at how to think of functionality from an object-oriented point of view.
Pages:
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121