Microsoft OLE DB Remoting Provider

[Previous] [Next]

There's another way you can execute remote queries using the RDS technology—by using the Microsoft OLE DB Remoting Provider, known as MS Remote. Instead of using a DataControl object or a DataSpace object and a DataFactory object to retrieve a Recordset, you can use the ADO Connection object and a connection string that references the MS Remote provider. You can supply a connection string and a query string to the MS Remote provider as shown here:

 strConn = "Provider=MS Remote;Remote Server=http://scep;" & _ "Remote Provider=SQLOLEDB;Data Source=Gilliam;" & _ "Initial Catalog=Northwind;User ID=sa;Password=;" Set cnNorthwind = New ADODB.Connection cnNorthwind.Open strConn strSQL = "SELECT * FROM Customers" Set rsCustomers = New ADODB.Recordset rsCustomers.Open strSQL, cnNorthwind, adOpenStatic, _ adLockBatchOptimistic, adCmdText 

Notice that the connection string is similar to the connection string you'd use with straight ADO while running on the local network. MS Remote is now your provider, and the provider you want to use to connect to your database is now the Remote Provider. (This is similar to what happens when you use the MSDataShape provider and call it the Data Provider.) Specify the IIS server and protocol you want to use in the Remote Server argument. You can also use an Internet Timeout argument to specify a value that you'd otherwise use in the InternetTimeout property of the RDS DataControl or DataSpace object.

If you want to use the MS Remote provider with a handler, you can use code such as the following. Note that you substitute a connection string and query string as specified in the handler's settings:

 strConn = "Provider=MS Remote;Remote Server=http://scep;" & _ "Handler=MSDFMap.Handler;Data Source=CustomerDatabase;" Set cnNorthwind = New ADODB.Connection cnNorthwind.Open strConn strSQL = "GetAllCustomers" Set rsCustomers = New ADODB.Recordset rsCustomers.Open strSQL, cnNorthwind, adOpenStatic, _ adLockBatchOptimistic, adCmdText 

I'll admit that, initially, I preferred using the DataControl and DataFactory objects. But the more I used the MS Remote provider, the more it felt like a logical extension of ADO to the Internet.



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