asp.net.ph

SqlDataSource.ProviderName Property

System.Web.UI.WebControls Namespace   SqlDataSource Class


.NET Framework version 2.0

Returns the name of the .NET data provider that the SqlDataSource control uses to connect to an underlying data source.

Syntax


Inline <asp:SqlDataSource providername = strProviderName ... >
Script SqlDataSource.ProviderName [ = strProviderName ]

Property Value


strProviderName The name of the data provider that the SqlDataSource uses; otherwise, the ADO.NET provider for Microsoft SQL Server™, if no provider is set.

The property is read/write with a default value of System.Data.SqlClient.

Remarks

The .NET Framework includes the following data providers:

  • The System.Data.SqlClient provider is the default .NET Framework Data Provider for SQL Server™.
  • The System.Data.OleDb provider is the .NET Framework Data Provider for OLE DB.
  • The System.Data.Odbc provider is the .NET Framework Data Provider for ODBC.
  • The System.Data.OracleClient provider is the .NET Framework Data Provider for Oracle.

The ProviderName property is never set to the name of an unmanaged ADO.NET provider, such as MSDAORA. For more information, see Selecting Data Using the SqlDataSource Control.

If you change the ProviderName property, the DataSourceChanged event is raised, causing any controls that are bound to the SqlDataSource to rebind.

A list of available providers is specified in the DbProviderFactories subsection of the system.data section of the Machine.config file.

Example

The following example demonstrates how to connect to a SQL Server database using the default data provider. Note that whenever the ProviderName property is not explicitly set, the default provider for the SqlDataSource control ( System.Data.SqlClient ) is used.

<asp:sqldatasource id = "customers" runat = "server"
   datasourcemode = "datareader"
   selectcommand = "SELECT DISTINCT CustomerId, CompanyName FROM [Orders Summary]" 
   connectionstring = "<%$ ConnectionStrings:aspnet %>" />

 Show me 

NOTE: The syntax for the ConnectionString property is specific to each provider.

The following code example, which is functionally the same as the preceding code example, demonstrates how to connect to an ODBC database using the .NET Framework Data Provider for ODBC, the System.Data.Odbc. The ConnectionString property is set to the name of an ODBC data source name ( DSN ) that is used to connect to the ODBC database.

<asp:sqldatasource id = "employers" runat = "server"
   datasourcemode = "datareader"
   providername = "System.Data.Odbc"
   connectionstring = "dsn=odbcconn;"
   selectcommand = "select lastname from employees" />

<asp:listbox id = "employersList" runat = "server"
   datatextfield = "lastname"
   datasourceid = "employers" />
See Also

ConnectionString Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph