System.Data.SqlClient Namespace SqlDataAdapter Class
Initializes a new instance of the SqlDataAdapter class.
1. Initializes a new instance of the SqlDataAdapter class.
2. Initializes a new instance of the SqlDataAdapter class with the specified SqlCommand object.
3. Initializes a new instance of the SqlDataAdapter class with the specified Transact-SQL SELECT statement and a connection string.
4. Initializes a new instance of the SqlDataAdapter class with the specified Transact-SQL SELECT statement and an SqlConnection object.
The following example initializes an SqlDataAdapter, then fills a DataSet.
NOTE: This example uses one of the overloaded versions of the SqlDataAdapter constructor. For other examples that may be available, see the individual overload topics.
// set up the connection
string connString = "server=localhost; trusted_connection=yes; database=pubs";
// set up the query
string query = "SELECT * FROM authors";
// set up the adapter
SqlDataAdapter myAdapter = new SqlDataAdapter ( query, connString );
// instantiate 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 the query
dim query as string = "SELECT * FROM authors";
' set up the adapter
dim myAdapter as new SqlDataAdapter ( query, connString )
' instantiate dataset object
dim myData as new DataSet ( )
' fill with query results
myAdapter.Fill ( myData, "authors" ) |
|
C# |
VB |
SqlDataAdapter Members