Export (0) Print
Expand All

SqlDataSource Constructor (String, String, String)

Initializes a new instance of the SqlDataSource class with the specified connection string and Select command.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

new : 
        providerName:string * 
        connectionString:string * 
        selectCommand:string -> SqlDataSource

Parameters

providerName
Type: System.String

The name of the data provider that the SqlDataSource uses. If no provider is set, the SqlDataSource uses the ADO.NET provider for Microsoft SQL Server, by default.

connectionString
Type: System.String

The connection string used to connect to the underlying database.

selectCommand
Type: System.String

The SQL query used to retrieve data from the underlying database. If the SQL query is a parameterized SQL string, you might need to add Parameter objects to the SelectParameters collection.

Because different database products use different varieties of SQL, the syntax of selectCommand depends on the current ADO.NET provider being used, which is identified by the providerName parameter. If the SQL string is a parameterized query or command, the placeholder of the parameter also depends on the ADO.NET provider being used. For example, if the provider is System.Data.SqlClient, which is the default provider for the SqlDataSource class, the placeholder of the parameter is '@parameterName'. However, if the provider is set to the System.Data.Odbc or the System.Data.OleDb, the placeholder of the parameter is '?'. For more information about parameterized SQL queries and commands, see Using Parameters with the SqlDataSource Control.

The SelectCommand property can be an SQL string or the name of a stored procedure, if the data source supports stored procedures.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft