MySQL Error 1126

October 20th, 2009

ERROR 1126 (HY000): Can't open shared library
If you receive the error from MySQL while installing a plugin or a user defined function(UDF) there can be several causes:

  1. You mistyped your dll file name, double check the name
  2. MySQL can’t find the dll file in the plugin folder
    1. Run:
      mysql> show variables like 'plugin_dir';
    2. And make sure that path matches the path where your dll is stored.
  3. A dependent dll can’t be found
    1. Download Dependency Walker from http://www.dependencywalker.com/
    2. Open your dll on the machine you’re installing the plugin. It should tell you if there was a missing dependency

In my case it turned out the be #3.

dependencywalkerror

Dependency walker said I was missing MSVCR90D.dll, which I learned from Stack Overflow is actually the debug build of MSVCR90 (Notice: the “D” on the end).  So I went back to Visual Studio Express 2008 and made sure my configuration was set to Release and rebuilt the build and copied it over and everything worked.

Raw SQL Queries with NHibernate

October 17th, 2009

If you want to execute a native SQL query and don’t care about the result, just grab the ADO.NET database connection from the NHibernate session and use that to run the query.

Here’s the code:

// Get the NHibernate Session (this line will change depending how you do it)
NHibernate.ISession session = SessionManager.GetInstance();
// Create a SQL Command
System.Data.IDbCommand command = session.Connection.CreateCommand();
// Set the query you're going to run
command.CommandText = "INSERT INTO Users ('Peter', 'Piper')";
// Run the query
command.ExecuteNonQuery();