Table of Contents
Preface and Legal Notices .................................................................................................................. v
1 Introduction to MySQL Connector/NET ............................................................................................. 1
2 Connector/NET Versions ................................................................................................................. 3
3 Connector/NET Installation .............................................................................................................. 7
3.1 Installing Connector/NET on Windows ................................................................................... 7
3.1.1 Installing Connector/NET Using the Standalone Installer .............................................. 7
3.1.2 Installing Connector/NET Using NuGet ....................................................................... 8
3.2 Installing Connector/NET on Unix with Mono ....................................................................... 10
3.3 Installing Connector/NET from Source ................................................................................. 10
4 Connector/NET Connections .......................................................................................................... 13
4.1 Creating a Connector/NET Connection String ...................................................................... 13
4.2 Managing a Connection Pool in Connector/NET ................................................................... 16
4.3 Handling Connection Errors ................................................................................................ 17
4.4 Connector/NET Authentication ............................................................................................. 18
4.5 Connector/NET Connection Options Reference .................................................................... 23
5 Connector/NET Programming ........................................................................................................ 41
5.1 Using GetSchema on a Connection ..................................................................................... 42
5.2 Using MySqlCommand ....................................................................................................... 44
5.3 Using Connector/NET with Table Caching ........................................................................... 47
5.4 Preparing Statements in Connector/NET .............................................................................. 47
5.5 Creating and Calling Stored Procedures .............................................................................. 48
5.6 Handling BLOB Data With Connector/NET ........................................................................... 52
5.6.1 Preparing the MySQL Server ................................................................................... 53
5.6.2 Writing a File to the Database .................................................................................. 53
5.6.3 Reading a BLOB from the Database to a File on Disk ............................................... 55
5.7 Working with Partial Trust / Medium Trust ............................................................................ 56
5.7.1 Evolution of Partial Trust Support Across Connector/NET Versions ............................. 57
5.7.2 Configuring Partial Trust with Connector/NET Library Installed in GAC ........................ 57
5.7.3 Configuring Partial Trust with Connector/NET Library Not Installed in GAC .................. 59
5.8 Writing a Custom Authentication Plugin ............................................................................... 60
5.9 Using the Connector/NET Interceptor Classes ..................................................................... 63
5.10 Handling Date and Time Information in Connector/NET ...................................................... 65
5.10.1 Fractional Seconds ................................................................................................ 65
5.10.2 Problems when Using Invalid Dates ........................................................................ 65
5.10.3 Restricting Invalid Dates ......................................................................................... 66
5.10.4 Handling Invalid Dates ........................................................................................... 66
5.10.5 Handling NULL Dates ............................................................................................ 66
5.11 Using the MySqlBulkLoader Class ..................................................................................... 67
5.12 Connector/NET Tracing ..................................................................................................... 68
5.12.1 Enabling OpenTelemetry Tracing ............................................................................ 68
5.12.2 Using the Connector/NET Trace Source Object ....................................................... 69
5.13 Using Connector/NET with Crystal Reports ........................................................................ 74
5.13.1 Creating a Data Source .......................................................................................... 74
5.13.2 Creating the Report ................................................................................................ 75
5.13.3 Displaying the Report ............................................................................................. 76
5.14 Asynchronous Methods ..................................................................................................... 79
5.15 Binary and Nonbinary Issues ............................................................................................. 85
5.16 Character Set Considerations for Connector/NET ............................................................... 86
6 Connector/NET Tutorials ................................................................................................................ 87
6.1 Tutorial: An Introduction to Connector/NET Programming ..................................................... 87
6.1.1 The MySqlConnection Object ................................................................................... 87
iii