List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:July 27 2010 7:46pm
Subject:bzr commit into connector-net-6.2 branch (reggie.burnett:877)
View as plain text  
#At file:///C:/work/connector-net/6.2/ based on revid:vvaintroub@stripped

  877 Reggie Burnett	2010-07-27 [merge]
      merged

    modified:
      CHANGES
      MySql.VisualStudio/Nodes/StoredProcedureNode.cs
=== modified file 'CHANGES'
=== modified file 'CHANGES'
--- a/CHANGES	2010-07-26 16:30:20 +0000
+++ b/CHANGES	2010-07-27 19:46:33 +0000
@@ -35,6 +35,7 @@
   the databasename in our typed datasets.  This allows users to move the dataset to a new
   database/server with no trouble (bug #33870)
 - fixed recognition of char(36) columns to be guids when used in views with entity models (bug #52085)
+- fixed visual studio plugin so that stored procedure editing works on older versions of MySQL (bug #55170)
 
 Version 6.2.3
 - fixed InvalidOperationException when accessing Stream.ReadTimeout or Stream.WriteTimeout on CF

=== modified file 'MySql.VisualStudio/Nodes/StoredProcedureNode.cs'
--- a/MySql.VisualStudio/Nodes/StoredProcedureNode.cs	2009-04-23 14:37:37 +0000
+++ b/MySql.VisualStudio/Nodes/StoredProcedureNode.cs	2010-07-27 19:42:46 +0000
@@ -121,21 +121,44 @@
             {
                 try
                 {
-                    DataTable dt = GetDataTable(String.Format("SHOW CREATE {0} `{1}`.`{2}`",
-                            IsFunction ? "FUNCTION" : "PROCEDURE", Database, Name));
-
-                    sql_mode = dt.Rows[0][1] as string;
-                    string sql = dt.Rows[0][2] as string;
+                    string sql = GetStoredProcedureBody(String.Format(
+                        "SHOW CREATE {0} `{1}`.`{2}`", 
+                        IsFunction ? "FUNCTION" : "PROCEDURE", Database, Name), out sql_mode);
                     editor.Text = ChangeSqlTypeTo(sql, "ALTER");
                     Dirty = false;
                 }
                 catch (Exception ex)
                 {
-                    MessageBox.Show("Unable to load object with error: " + ex.Message);
+                    MessageBox.Show("Unable to load the stored procedure for editing");
                 }
             }
 		}
 
+        private string GetStoredProcedureBody(string sql, out string sql_mode)
+        {
+            string body = null;
+
+            DbConnection conn = (DbConnection)HierarchyAccessor.Connection.GetLockedProviderObject();
+            try
+            {
+
+                DbCommand cmd = MySqlProviderObjectFactory.Factory.CreateCommand();
+                cmd.Connection = conn;
+                cmd.CommandText = sql;
+                using (DbDataReader reader = cmd.ExecuteReader())
+                {
+                    reader.Read();
+                    sql_mode = reader.GetString(1);
+                    body = reader.GetString(2);
+                }
+                return body;
+            }
+            finally
+            {
+                HierarchyAccessor.Connection.UnlockProviderObject();
+            }
+        }
+
         /// <summary>
         /// We override save here so we can change the sql from create to alter on
         /// first save


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20100727194633-lipu1iakd0kpyjsk.bundle
Thread
bzr commit into connector-net-6.2 branch (reggie.burnett:877) Reggie Burnett27 Jul