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.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...