Connector/Net Programming
1926
Treating Binary Blobs As UTF8
MySQL doesn't currently support 4-byte UTF8 sequences. This makes it difficult to represent some
multi-byte languages such as Japanese. To try and alleviate this, Connector/Net now supports a mode
where binary blobs can be treated as strings.
To do this, you set the
'Treat Blobs As UTF8'
connection string keyword to
yes
. This is
all that needs to be done to enable conversion of all binary blobs to UTF8 strings. To convert
only some of your BLOB columns, you can make use of the
'BlobAsUTF8IncludePattern'
and
'BlobAsUTF8ExcludePattern'
keywords. Set these to a regular expression pattern that
matches the column names to include or exclude respectively.
When the regular expression patterns both match a single column, the include pattern is applied before
the exclude pattern. The result, in this case, would be that the column would be excluded. Also, be
aware that this mode does not apply to columns of type
BINARY
or
VARBINARY
and also do not apply
to nonbinary
BLOB
columns.
Currently, this mode only applies to reading strings out of MySQL. To insert 4-byte UTF8 strings into
blob columns, use the .NET
Encoding.GetBytes
function to convert your string to a series of bytes.
You can then set this byte array as a parameter for a
BLOB
column.
20.2.5.17. Using Connector/Net with Crystal Reports
Crystal Reports is a common tool used by Windows application developers to perform reporting and
document generation. In this section we will show how to use Crystal Reports XI with MySQL and
Connector/Net.
20.2.5.17.1. Creating a Data Source
When creating a report in Crystal Reports there are two options for accessing the MySQL data while
designing your report.
The first option is to use Connector/ODBC as an ADO data source when designing your report. You will
be able to browse your database and choose tables and fields using drag and drop to build your report.
The disadvantage of this approach is that additional work must be performed within your application to
produce a data set that matches the one expected by your report.
The second option is to create a data set in VB.NET and save it as XML. This XML file can then be
used to design a report. This works quite well when displaying the report in your application, but is less
versatile at design time because you must choose all relevant columns when creating the data set. If
you forget a column you must re-create the data set before the column can be added to the report.
The following code can be used to create a data set from a query and write it to disk:
Visual Basic Example
Dim myData As New DataSet
Dim conn As New MySqlConnection
Dim cmd As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
conn.ConnectionString = "server=127.0.0.1;" _
& "uid=root;" _
& "pwd=12345;" _
& "database=world"
Try
conn.Open()
cmd.CommandText = "SELECT city.name AS cityName, city.population AS CityPopulation, " _
& "country.name, country.population, country.continent " _
& "FROM country, city ORDER BY country.continent, country.name"
cmd.Connection = conn
Содержание 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 ...