*/
If you have a PH account, you can customize your PH profile.

Other Views

corner
*/

ADONET FAQ - Defining a Data Adapter

How do I define a data adapter?

The data adapter stores your command (query) and connection and using these connect to the database when asked, fetch the result of query and store it in the local dataset.

The DataAdapter class (SqlDataAdapter, OracleDataAdapter, OleDbDataAdapter, OdbcDataAdapter) may be instantiated in three ways:

  1. by supplying the command string (SQL Select command) and connection string
  2. by supplying the command string (SQL Select command) and a connection object
  3. by supplying the command object (SqlCommand, OracleCommand, OleDbCommand, OdbcCommand)
For example, with SQL Server, the data adapter is created as

C# Version
// for Sql Server
SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, conn);


VB.Net Version
Dim da As New SqlDataAdapter(commandString, conn)


Here we have created a new instance of data adapter and supplied it command string and connection object in the constructor call.

For Access, the data adapter is created like

C# Version
// for MS Access
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(commandString, connectionString);


VB.Net Version
Dim da As New OleDbDataAdapter(commandString, connectionString)


Here we have created a new instance of data adapter and supplied it command string and connection string in the constructor call.

Back
corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.