Connector/Net Programming
1920
conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.WriteLine("Done.");
}
}
}
Further information on
LOAD DATA INFILE
can be found in
Section 13.2.6, “
LOAD DATA INFILE
Syntax”
. Further information on
MySqlBulkLoader
can be found in the reference documentation that
was included with your connector.
20.2.5.14. Using the MySQL Connector/Net Trace Source Object
MySQL Connector/Net 6.2 introduced support for .NET 2.0 compatible tracing, using
TraceSource
objects.
The .NET 2.0 tracing architecture consists of four main parts:
• Source - This is the originator of the trace information. The source is used to send trace messages.
The name of the source provided by MySQL Connector/Net is
mysql
.
• Switch - This defines the level of trace information to emit. Typically, this is specified in the
app.config
file, so that it is not necessary to recompile an application to change the trace level.
• Listener - Trace listeners define where the trace information will be written to. Supported listeners
include, for example, the Visual Studio Output window, the Windows Event Log, and the console.
• Filter - Filters can be attached to listeners. Filters determine the level of trace information that will be
written. While a switch defines the level of information that will be written to all listeners, a filter can
be applied on a per-listener basis, giving finer grained control of trace information.
To use tracing a
TraceSource
object first needs to be created. To create a
TraceSource
object in
MySQL Connector/Net you would use code similar to the following:
TraceSource ts = new TraceSource("mysql");
To enable trace messages, configure a trace switch. There are three main switch classes,
BooleanSwitch
,
SourceSwitch
, and
TraceSwitch
. Trace switches also have associated with
them a trace level enumeration, these are
Off
,
Error
,
Warning
,
Info
, and
Verbose
. The following
code snippet illustrates creating a switch:
ts.Switch = new SourceSwitch("MySwitch", "Verbose");
This creates a
SourceSwitch
, called
MySwitch
, and sets the trace level to
Verbose
, meaning that
all trace messages will be written.
It is convenient to be able to change the trace level without having to recompile the code. This is
achieved by specifying the trace level in application configuration file,
app.config
. You then simply
need to specify the desired trace level in the configuration file and restart the application. The trace
source is configured within the
system.diagnostics
section of the file. The following XML snippet
illustrates this:
<configuration>
...
<system.diagnostics>
<sources>
<source name="mysql" switchName="MySwitch"
switchType="System.Diagnostics.SourceSwitch" />
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 ...