Namespace:
MySql.Data.MySqlClient
Assembly:
MySql.Data (in MySql.Data.dll) Version: 6.2.2.0
Syntax
C# |
---|
public sealed class MySqlDataAdapter : DbDataAdapter, IDbDataAdapter, IDataAdapter, ICloneable |
Visual Basic (Declaration) |
---|
Public NotInheritable Class MySqlDataAdapter _ Inherits DbDataAdapter _ Implements IDbDataAdapter, IDataAdapter, ICloneable |
Visual C++ |
---|
public ref class MySqlDataAdapter sealed : public DbDataAdapter, IDbDataAdapter, IDataAdapter, ICloneable |
Remarks
The MySQLDataAdapter, serves as a bridge between a DataSet and MySQL for retrieving and saving data. The MySQLDataAdapter provides this bridge by mapping Fill(DataSet), which changes the data in the DataSet to match the data in the data source, and Update(DataSet), which changes the data in the data source to match the data in the DataSet, using the appropriate SQL statements against the data source.
When the MySQLDataAdapter fills a DataSet, it will create the necessary tables and columns for the returned data if they do not already exist. However, primary key information will not be included in the implicitly created schema unless the MissingSchemaAction property is set to AddWithKey. You may also have the MySQLDataAdapter create the schema of the DataSet, including primary key information, before filling it with data using FillSchema(DataTable, SchemaType).
MySQLDataAdapter is used in conjunction with MySqlConnection and MySqlCommand to increase performance when connecting to a MySQL database.
The MySQLDataAdapter also includes the SelectCommand, InsertCommand, DeleteCommand, UpdateCommand, and TableMappings properties to facilitate the loading and updating of data.
When an instance of MySQLDataAdapter is created, the read/write properties are set to initial values. For a list of these values, see the MySQLDataAdapter constructor.
Examples
Public Function SelectRows(dataSet As DataSet, connection As String, query As String) As DataSet Dim conn As New MySqlConnection(connection) Dim adapter As New MySqlDataAdapter() adapter.SelectCommand = new MySqlCommand(query, conn) adapter.Fill(dataset) Return dataset End Function
public DataSet SelectRows(DataSet dataset,string connection,string query) { MySqlConnection conn = new MySqlConnection(connection); MySqlDataAdapter adapter = new MySqlDataAdapter(); adapter.SelectCommand = new MySqlCommand(query, conn); adapter.Fill(dataset); return dataset; }
Inheritance Hierarchy
System..::.MarshalByRefObject
System.ComponentModel..::.Component
System.Data.Common..::.DataAdapter
System.Data.Common..::.DbDataAdapter
MySql.Data.MySqlClient..::.MySqlDataAdapter