Connector/Net Programming
1896
3. From the Solution Explorer select Add, New Item. In the Add New Item dialog select Online
Templates. Select ADO.NET Entity Data Model and click Add. The Entity Data Model dialog will
be displayed.
4. In the Entity Data Model dialog select Empty Model. Click Finish. A blank model will be created.
5. Create a simple model. A single Entity will do for the purposes of this tutorial.
6. In the Properties panel select ConceptualEntityModel from the drop-down listbox.
7. In the Properties panel, locate the DDL Generation Template in the category Database Script
Generation.
8. For the DDL Generation property select SSDLToMySQL.tt(VS) from the drop-down listbox.
9. Save the solution.
10. Right-click an empty space in the model design area. The context-sensitive menu will be displayed.
11. From the context-sensitive menu select Generate Database from Model. The Generate Database
Wizard dialog will be displayed.
12. In the Generate Database Wizard dialog select an existing connection, or create a new connection
to a server. Select an appropriate radio button to show or hide sensitive data. For the purposes of
this tutorial you can select Yes (although you might skip this for commercial applications).
13. Click Next. MySQL compatible DDL code will be generated. Click Finish to exit the wizard.
You have seen how to create MySQL DDL code from an Entity Framework model.
20.2.5. Connector/Net Programming
Connector/Net comprises several classes that are used to connect to the database, execute queries
and statements, and manage query results.
The following are the major classes of Connector/Net:
•
MySqlCommand
: Represents an SQL statement to execute against a MySQL database.
•
MySqlCommandBuilder
: Automatically generates single-table commands used to reconcile
changes made to a DataSet with the associated MySQL database.
•
MySqlConnection
: Represents an open connection to a MySQL Server database.
•
MySqlDataAdapter
: Represents a set of data commands and a database connection that are used
to fill a data set and update a MySQL database.
•
MySqlDataReader
: Provides a means of reading a forward-only stream of rows from a MySQL
database.
•
MySqlException
: The exception that is thrown when MySQL returns an error.
•
MySqlHelper
: Helper class that makes it easier to work with the provider.
•
MySqlTransaction
: Represents an SQL
transaction
to be made in a MySQL database.
In the following sections, you will learn about some common use cases for Connector/Net, including
BLOB handling, date handling, and using Connector/Net with common tools such as Crystal Reports.
20.2.5.1. Connecting to MySQL Using Connector/Net
All interaction between a .NET application and the MySQL server is routed through a
MySqlConnection
object. Before your application can interact with the server, it must instantiate,
configure, and open a
MySqlConnection
object.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...