System.Data.SqlClient Namespace SqlDataAdapter Class
Sets or retrieves a command used to select records in the data source.
[ VB ]
Public Property SelectCommand As SqlCommand
[ C# ]
public SqlCommand SelectCommand {get; set;}
[ C++ ]
public: __property SqlCommand* get_SelectCommand ( );
public: __property void set_SelectCommand ( SqlCommand* );
[ JScript ]
public function get SelectCommand ( ) : SqlCommand;
public function set SelectCommand ( SqlCommand );
An SqlCommand used during Fill to select records from the data source for loading into the DataSet.
When SelectCommand is assigned to a previously created SqlCommand, the SqlCommand is not cloned. The SelectCommand maintains a reference to the previously created SqlCommand object.
If the SelectCommand does not return any rows, no tables are added to the DataSet, but no exception is raised.
The following example illustrates use of the SelectCommand property.
void SelectCommandDemo ( ) {
SqlDataAdapter myAdapter = new SqlDataAdapter ( );
myAdapter.SelectCommand.CommandText = "SELECT * FROM Categories ";
myAdapter.SelectCommand.Connection = new SqlConnection
( "uid=sa; pwd=; database=northwind; server=myServer" );
}
public sub SelectCommandDemo ( )
dim myAdapter as new SqlDataAdapter ( )
myAdapter.SelectCommand.CommandText = "SELECT * FROM Categories "
myAdapter.SelectCommand.Connection = new SqlConnection
( "uid=sa; pwd=; database=northwind; server=myServer" )
end sub |
|
C# |
VB |
SqlDataAdapter Members DeleteCommand InsertCommand UpdateCommand