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

  905 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:35:10 +0000
+++ b/CHANGES	2010-07-27 19:48:14 +0000
@@ -1,3 +1,6 @@
+
+- fixed visual studio plugin so that stored procedure editing works on older versions of MySQL (bug #55170)
+
 Version 6.3.3 (beta 2)
 - fix "There is already an open DataReader..." after exceptions in DataReader.Close()
  (bug#55558)

=== modified file 'MySql.VisualStudio/Nodes/StoredProcedureNode.cs'
--- a/MySql.VisualStudio/Nodes/StoredProcedureNode.cs	2010-04-02 19:24:57 +0000
+++ b/MySql.VisualStudio/Nodes/StoredProcedureNode.cs	2010-07-27 19:48:14 +0000
@@ -122,21 +122,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-20100727194814-w33amz3lcdmt3evd.bundle
Thread
bzr commit into connector-net-trunk branch (reggie.burnett:905) Reggie Burnett27 Jul