Database Programming in C# with MySQL : Using OleDB - OleDB continued
(Page 2 of 4 )
OleDbDataAdapter represents a set of commands and a connection that is used to fill a DataSet. In other words it is a bridge between a DataSet and the data source to retrieve and update the data. The constructor of the OleDbDataAdapter needs to be called with a SQL select statement and an OleDbConnection instance. To cite an example, the following creates an instance of an OleDbDataAdapter named adapter:
OleDbDataAdapter adapter = new OleDbDataAdapter(queryString, conn);
OleDbDataReader provides a mechanism for reading forward only a stream of records and columns from the data source. To obtain an instance of OleDbDataReader, the executeReader() method of OleDbCommand has to be called. The following statement does the same:
OleDbDataReader reader = command.ExecuteReader();
Keep in mind that, while OleDbDataReader is being used, the corresponding connection will be busy, as it uses a stream to communicate with the data source.
Since the main classes have been discussed, the next step involves understanding how MySQL and the OleDB Data Provider link with each other. The OleDB Data Provider calls the underlying OleDB Provider. So it is the OleDB Provider that communicates with the data source. For each database system, the OleDB Provider has to be provided by the vendor of the database.
In this case the vendor is MySQL. Hence unless MySQL provides the OleDB Provider, the OleDB Data Provider won't be able to communicate with the database server. The Provider supplied by MySQL has to be registered with .Net so that the OleDB Data Provider can call the Provider. The other term for the OleDB Provider is Database Driver. In the case of MySQL it is also known as the MySQL connector. Next I will be discussing the steps required to access MySQL.
Next: Accessing MySQL, Step by Step >>
More Database Articles
More By A.P.Rajshekhar