Archive for the ‘ado.net’ Category

MySQL Connector/Net 6.5.1 beta has been released

Январь 26th, 2012
MySQL Connector/Net 6.5.1, a new version of the all-managed .NET driver for MySQL has been released.  This is a beta release of our newest connector and comes with several new features.  It is of beta quality and should not be used in any production environment.  It is appropriate for use with MySQL server versions 5.0-5.6

It is now available in source and binary form from http://dev.mysql.com/downloads/connector/net/#downloads and mirror sites (note that not all mirror sites may be up to date at this point-if you can't find this version on some mirror, please try again later or choose another download site.)

This new versions brings new features such as
  • Exception and command injector support
  • Millseconds support
  • Better partial-trust support
  • Better intellisense including auto-completion when editing stored procedures or .mysql files
These features are not yet documented in the shipping documentation.  We have posted a series of posts to our blog outlining these new features.

You can leave comments here on the blog post or post questions on our forums at http://forums.mysql.com/

Enjoy and thanks for the support!      
PlanetMySQL Voting: Vote UP / Vote DOWN

Intellisense Support

Январь 3rd, 2012

 Intellisense Support in Visual Studio

One of the cool features coming in Connector/NET 6.5 is the support in Visual Studio 2010 of Intellisense for MySql files.

As you probably know, the capability of editing mysql files (in the way of both .mysql raw files included in the solution and stored procedures/functions from Server Explorer) has been around for a while, yet a missing piece of the puzzle was to have advanced completion of sql statements in those files… until now.

Let’s explore the set of features currently implemented as part of Intellisense support.

Note: For completion intellisense features to work a database connection must be properly configured, see images below


For Server Explorer items, the connection is the root of the elements.
For .mysql files, the connection is individually configured using the Connect to MySql toolbar button.

Also to trigger the completion features you just either use the standard Visual Studio shortcut “Control+J” or start typing the name of an object. Both ways to trigger intellisense work in all syntactical contexts.

a) Table Completion

Table completion means showing the list of tables for the current connection database in the proper syntactical context. Basically this means any part of a sql sentence where the parser expects a table. Some examples of this feature follow:

After the “from” clause in a select, you can press Control+J and get a list of all the tables from the current connection database.
After selecting one of the options, the text appears wrapped in quotes (to cover the case when the table name has whitespaces or is a mysql reserved word).
Or you can start typing the name of a table, and the list shows only those items that match.
Another example, after an inner join.
Another example, in an update statement. Also notice that you can have several sentences on the file, but the previous sentences must be correct syntactically (included being finished with a semicolon).
Another example, on the insert statement.
As expected, combinations like insert into select, also work.
Table completion for a delete statement.
For show create table statements.
For truncate statements.

And of course there are many others.

b) Column Completion

Column completion means showing the list of columns for the current connection database table or tables in the proper syntactical context. Basically this means any part of a sql sentence where the parser expects a column. Some examples of this feature follow:

After a select without from clause you can get, by Control+J, the list of columns for all tables in the current database.
If you type c, the lists shown filters out items whose name doesn’t start with the characters typed.
Things get more interesting when there is a context restricting the tables to use, like here, after the “*, “.
What if you add the same table several times with different alias? Then the list of columns is prefixed with the alias name, not the table name. Also works in where clauses.
“Set” clause in Update statements.
“Order by” clauses.
“On” clause in a left join select statement.
Column completion on insert into statements.

And other cases not showed here.

If you want to see Intellisense within a stored procedure definition, the rest of the stored procedure (excluding the sentence currently being edited) must be syntactically correct.

c) Stored procedure name Completion

Stored procedure name completion means showing the list of stored procedures in the proper syntactical context.

For the call statement, you get the list of stored procedures; notice that when you highlight one, its signature appears as a tooltip.

For those of you interested in compiler technology, behind the scenes these intellisense features are powered by an ANTLR generated parser, this parser will also be the foundation for other interesting features…

Anyway, let us know what you think, if there are other things you want to see on Intellisense support or in the Connector/NET in general. (Or you can open a bug / feature request at http://bugs.mysql.com, Connector/NET category).


PlanetMySQL Voting: Vote UP / Vote DOWN

MySQL Connector/Net 6.5.0 beta has been released

Декабрь 23rd, 2011
MySQL Connector/Net 6.5.0, a new version of the all-managed .NET driver for MySQL has been released.  This is a beta release of our newest connector and comes with several new features.  It is of beta quality and should not be used in any production environment.  It is appropriate for use with MySQL server versions 5.0-5.6

It is now available in source and binary form from here and mirror sites (note that not all mirror sites may be up to date at this point-if you can't find this version on some mirror, please try again later or choose another download site.)

This new versions brings new features such as
  • Exception and command injector support
  • Millseconds support
  • Better partial-trust support
  • Better intellisense including auto-completion when editing stored procedures or .mysql files
These features are not yet documented in the shipping documentation.  We will be posting a series of posts to our blog outlining these new features and will have them fully documented by GA.

You can leave comments here on this blog or you can also post questions on our forums at http://forums.mysql.com/

Enjoy and thanks for the support! 
PlanetMySQL Voting: Vote UP / Vote DOWN

MySQL Connector/Net 6.3.8 has been released

Декабрь 22nd, 2011
MySQL Connector/Net 6.3.8, a new version of the all-managed .NET driver for MySQL has been released.  This is a maintenance release to our 6.3 release chain and includes 40 changes and fixes.

Version 6.3.8 is appropriate for use with versions of MySQL 5.0-5.5.

It is now available in source and binary form from here and mirror sites (note that not all mirror sites may be up to date at this point-if you can't find this version on some mirror, please try again later or choose another download site.)

The release is also available for download on My Oracle Support (MOS).

Enjoy and thanks for the support!
PlanetMySQL Voting: Vote UP / Vote DOWN

Enable MySQL Enterprise Plugin for Connector/NET

Июнь 15th, 2010

Figure 1. Source Location

In a prior post ( Trace SQL From Database to Source Code ), I showed how to enable SQL trace capabilities for java/MySQL application to trace SQL statements from the database to the exact line of code from which the statement was executed (see Figure 1).  In this post, I’ll enable SQL tracing in the sample C# application, which is included with the MySQL Connector/NET (MySQL’s ADO.NET provider ) install.

The following instructions assume that the MySQL Enterprise Agent and Monitor is already installed.  The Monitor is available for support customers at http://customer.mysql.com or a trial is available at http://www.mysql.com/trials .

Step #1.  Download and install the Connector/NET and the MySQL Enterprise Plugin for Connector/NET

  • Connector/NET 6.2.3 or newer version. The assembly is MySQL.Data.dll  Select the option to install the C# samples.
  • MySQL Enterprise Plugin for Connnector/NET ( http://customer.mysql.com or www.mysql.com/trials ). The assembly is MySQL.MonitorPlugin.dll

Step #2.  Copy the plugin, MySQL.MonitorPlugin.dll to your application directory.  In my case, I’m building and debugging the sample application using Microsoft Visual C# 2008 Express Edition.  The MySQL.MonitorPlugin.dll needs to reside in the same directly as the application’s executable.  Copy the dll to C:\Program Files\MySQL\MySQL Connector Net 6.2.3\Samples\Table Editor\cs\bin\Debug

Step #3.  Open the sample project TableEditor.csproj ( C:\Program Files\MySQL\MySQL Connector Net 6.2.3\Samples\Table Editor\cs\TableEditor.csproj ) in Microsoft Visual Studio and add an App.config file to the project.  For this exercise, I’m using Microsoft Visual C# 2008 Express Edition.

To add the App.config file, select Solution Explorer on the View menu, right-click on TableEditor, the project name.  Point to Add, New Item, and choose Application Configuration File.

In Solution Explorer, double-click App.config to open the file.  Replace the contents of the file with the XML below.  Note: replace the items in brackets [ ] with the appropriate information for your server.  (Omit the brackets) Likewise, the UserID and Password should match the credentials that the agent uses to authenticate to the Monitor.

Copy and paste the following into App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="mysql" switchName="SourceSwitch"    switchType="System.Diagnostics.SourceSwitch">
        <listeners>
          <add name="EMTrace" type="MySql.EMTrace.EMTraceListener, MySql.MonitorPlugin"
                    initializeData=""
            Host="[http://yourServer.com:18080]"
            PostInterval="60"
            UserId="[agent]"
            Password="[mysql]"/>
          </listeners>
      </source>
    </sources>
    <switches>
      <!-- You can set the level at which tracing is to occur -->
      <add name="SourceSwitch" value="All"/>
    </switches>
  </system.diagnostics>
</configuration>

[Note: if you're following the readme or documentation, you'll notice that I omitted the <system.data> section.  I believe this to be an error in the documentation.  In my testing, it never works with the <system.data> entry.]

Step #4.  Modify the connection string to include “logging = true”

Here’s the full connection string that I used while running the sample application:

string connStr = String.Format(“server={0};user id={1}; password={2}; database=mysql; port=3307; pooling=false; logging=true”,server.Text, userid.Text, password.Text );

Step #5.  Compile the application ( Debugging | Start Debugging (F5) ).   On Form1, enter the appropriate Server, User ID and Password for the MySQL Server and toggle the databases and tables.  Watch the Output window, select Output from the View menu in the IDE, and you should start seeing SQL debug information, which will be passed to the MySQL Enterprise Monitor.  In the App.config, the PostInterval is set to 30, meaning that it will take 30 seconds before the data is sent to the monitor.

If you’re a .NET developer, please give it a try.  The query analyzer provides a great view into your application and the database.



PlanetMySQL Voting: Vote UP / Vote DOWN

"Windows and MySQL" Slides Available

Октябрь 16th, 2009
Copies of the slides from the first two "Windows and MySQL" webinars are now available:

Part 1: Getting Started with MySQL on Windows
Part 2: MySQL for the SQL Server DBA

Also, if you missed Reggie Burnett's "MySQL and the ADO.NET Entity Framework" webinar a few weeks ago, his slides are also available here.

PlanetMySQL Voting: Vote UP / Vote DOWN