DataAdapter Select Command - Sql Server

The OleDbDataAdapter is an essential component of the ADO.NET Data Provider, responsible for facilitating communication between the Dataset and the Data Source through the OleDbConnection Object. It plays a crucial role in establishing a connection and retrieving data from the data source, while seamlessly working with the DataSet to provide a disconnected data retrieval mechanism.

OleDbDataAdapter

The SelectCommand property of the OleDbDataAdapter represents a Command object that retrieves data from the data source. By utilizing the Fill method, the OleDbDataAdapter populates a DataSet with the data obtained from the SelectCommand. The Fill method requires arguments such as a DataSet to be populated and a DataTable object (or the name of the DataTable) that will be filled with the rows returned from the SelectCommand. These features enable efficient data retrieval and population within the DataSet, ensuring effective management and manipulation of data.

Full Source C#
using System; using System.Data; using System.Data.OleDb; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string connetionString = null; OleDbConnection connection ; OleDbDataAdapter oledbAdapter = new OleDbDataAdapter(); DataSet ds = new DataSet(); int i = 0; connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;"; connection = new OleDbConnection(connetionString); try { connection.Open(); oledbAdapter.SelectCommand = new OleDbCommand("Your SQL Statement Here", connection); oledbAdapter.Fill(ds); oledbAdapter.Dispose(); connection.Close(); for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { MessageBox.Show (ds.Tables[0].Rows[i].ItemArray[0].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }