Sun
ONE Active Server Pages Product Home Page Developer Site Version
 

ContentsPreviousNextIndex



ADO Connection Object Provider Property

The name of the provider for a Connection object. This property is not available on UNIX.

Provider Property Return Values

Sets or returns a String value.

Provider Property Remarks

Use the Provider property to set or return the name of the provider for a connection. This property can also be set by the contents of the ConnectionString property or the ConnectionString argument of the ADO Connection Object Open Method; however, specifying a provider in more than one place while calling the Open method can have unpredictable results. If no provider is specified, the property will default to MSDASQL (Microsoft OLE DB Provider for ODBC).

The Provider property is read/write when the connection is closed and read-only when it is open. The setting does not take effect until you either open the Connection object or access the ADO Properties Collection of the Connection object. If the setting is invalid, an error occurs.

Provider Property Example

This Visual Basic example demonstrates the Provider property by opening two Connection objects using different providers. It also uses the DefaultDatabase property to set the default database for the Microsoft ODBC Provider.

Public Sub ProviderX() 
Dim cnn1 As ADODB.Connection 
Dim cnn2 As ADODB.Connection
` Open a connection using the Microsoft ODBC provider. 
Set cnn1 = New ADODB.Connection 
cnn1.ConnectionString = "driver={SQL Server};" & _ 
"server=bigsmile;uid=sa;pwd=pwd" 
cnn1.Open strCnn 
cnn1.DefaultDatabase = "pubs" 
` Display the provider. 
MsgBox "Cnn1 provider: " & cnn1.Provider
` Open a connection using the Microsoft Jet provider. 
Set cnn2 = New ADODB.Connection 
cnn2.Provider = "Microsoft.Jet.OLEDB.3.51" 
cnn2.Open "C:\Samples\northwind.mdb", "admin", ""
` Display the provider. 
MsgBox "Cnn2 provider: " & cnn2.Provider
cnn1.Close 
cnn2.Close 
End Sub


ContentsPreviousNextIndex