Using the Data Shape Provider

[Previous] [Next]

Microsoft Data Access Components (MDAC) includes a number of OLE DB providers that are considered "service providers." Rather than communicating directly with a database, you utilize the services of these providers. One prime example of such a service provider is the OLE DB provider for data shaping—often referred to as MSDataShape. In this text, I'll also refer to the provider as the "data shape provider."

The features described throughout this chapter require the use of the MSDataShape provider. To use the functionality exposed by this provider, you have to reference the provider when you connect to your database. Luckily, referencing this provider requires only a small change in your connection string. If your normal connection string was

 strConn = "Provider=SQLOLEDB;Data Source=ScepHome;" & _ "Initial Catalog=Northwind;" 

you would change it to

 strConn = "Provider=MSDataShape;Data Provider=SQLOLEDB;" & _ "Data Source=ScepHome;Initial Catalog=Northwind;" 

to use the MSDataShape provider. Simply put, what you normally used as your provider is now the "data provider"—the OLE DB provider that MSDataShape will use to communicate with your database.

If you use properties exposed by the Connection object to connect to your database rather than using a connection string to do so, the Connection object will expose a Data Provider property in its dynamic Properties collection after you set the Provider property to MSDataShape. Thus, instead of connecting with code such as

 cnNorthwind.Provider = "SQLOLEDB" cnNorthwind.Properties("Data Source") = "ScepHome" cnNorthwind.Properties("Initial Catalog") = "Northwind" 

you would use code such as

 cnNorthwind.Provider = "MSDataShape" cnNorthwind.Properties("Data Provider") = "SQLOLEDB" cnNorthwind.Properties("Data Source") = "ScepHome" cnNorthwind.Properties("Initial Catalog") = "Northwind" 

Once you've connected to your database using the MSDataShape provider, you can continue to run your standard nonhierarchical queries as you normally would.



Programming ADO
Programming MicrosoftВ® ADO.NET 2.0 Core Reference
ISBN: B002ECEFQM
EAN: N/A
Year: 2000
Pages: 131
Authors: David Sceppa

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net