System.Data.SqlClient Namespace SqlDataAdapter Class
Initializes a new instance of the SqlDataAdapter class with the specified SqlCommand object.
[ VB ]
Overloads Public Sub New ( _
ByVal selectCommand As SqlCommand _
)
[ C# ]
public SqlDataAdapter (
SqlCommand selectCommand
);
[ C++ ]
public: SqlDataAdapter (
SqlCommand* selectCommand
);
[ JScript ]
public function SqlDataAdapter (
selectCommand : SqlCommand
);
- selectCommand
- An SqlCommand that is a Transact-SQL SELECT statement or stored procedure. This SqlCommand is internally set as the SelectCommand property of the SqlDataAdapter.
When an instance of SqlDataAdapter is created, the following read/write properties are set to initial values.
You can change the value of any of these properties through a separate call to the property.
When SelectCommand ( or any of the other command properties ) is assigned to a previously created SqlCommand, the SqlCommand is not cloned. The SelectCommand maintains a reference to the previously created SqlCommand object.
The following example initializes an SqlDataAdapter using this constructor, then fills a DataSet.
// set up the connection
string connString = "server=localhost; trusted_connection=yes; database=pubs";
// set up an SqlCommand
SqlCommand myCommand = new SqlCommand (
"SELECT * FROM authors", connString );
// set up the dataadapter
SqlDataAdapter myAdapter = new SqlDataAdapter ( myCommand );
// instantiate a dataset object
DataSet mydata = new DataSet ( );
// fill with query results
myAdapter.Fill ( myData, "authors" );
' set up the connection
dim connString as string = "server=localhost; trusted_connection=yes; database=pubs"
' set up an SqlCommand
dim myCommand as new SqlCommand ( _
"SELECT * FROM authors", connString )
' set up the dataadapter
dim myAdapter as new SqlDataAdapter ( myCommand )
' instantiate a dataset object
DataSet mydata = new DataSet ( )
' fill with query results
myAdapter.Fill ( myData, "authors" ) |
|
C# |
VB |
SqlDataAdapter Members SqlDataAdapter Constructor Overload List MissingMappingAction MissingSchemaAction