[Monodevelop-patches-list] r2774 - in trunk/MonoDevelop/Extras/MonoQuery: . Mono.Data.Sql Mono.Data.Sql/Providers MonoQuery MonoQuery/Gui MonoQuery/Gui/NodeBuilders tests
Christian Hergert <chris@mosaix.net>
chergert at mono-cvs.ximian.com
Sun Aug 21 06:22:53 EDT 2005
Author: chergert
Date: 2005-08-21 06:22:52 -0400 (Sun, 21 Aug 2005)
New Revision: 2774
Added:
trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/FirebirdDbProvider.cs
trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/OdbcDbProvider.cs
trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/SybaseDbProvider.cs
trunk/MonoDevelop/Extras/MonoQuery/tests/test-firebird-1.cs
trunk/MonoDevelop/Extras/MonoQuery/tests/test-oracle-1.cs
trunk/MonoDevelop/Extras/MonoQuery/tests/test-sybase-1.cs
Modified:
trunk/MonoDevelop/Extras/MonoQuery/ChangeLog
trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Makefile.am
trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Mono.Data.Sql.mdp
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/DbProviderCollection.cs
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/MonoQuery.mdp
trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/monoquery.glade
Log:
* tests/test-oracle-1.cs: Test. Will be converted to nunit later.
* tests/test-firebird-1.cs:
* tests/test-sybase-1.cs:
* MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: Do not append the
sql statement with `;' as this breaks oracle.
* MonoQuery/monoquery.glade: Make password hidden by default.
Passwords can be still seen in advanced textview. this is ok and done
on purpose.
* MonoQuery/MonoQuery.mdp: Updated
* Mono.Data.Sql/Makefile.am:
* Mono.Data.Sql/Providers/FirebirdDbProvider.cs: New firebird
provider.
* Mono.Data.Sql/Providers/SybaseDbProvider.cs: New sybase provider
* Mono.Data.Sql/Providers/OdbcDbProvider.cs: New generic odbc
connector.
* Mono.Data.Sql/Mono.Data.Sql.mdp: Updated
Modified: trunk/MonoDevelop/Extras/MonoQuery/ChangeLog
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/ChangeLog 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/ChangeLog 2005-08-21 10:22:52 UTC (rev 2774)
@@ -1,3 +1,22 @@
+2005-08-06 Christian Hergert <christian.hergert at gmail.com>
+
+ * tests/test-oracle-1.cs: Test. Will be converted to nunit later.
+ * tests/test-firebird-1.cs:
+ * tests/test-sybase-1.cs:
+ * MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs: Do not append the
+ sql statement with `;' as this breaks oracle.
+ * MonoQuery/monoquery.glade: Make password hidden by default.
+ Passwords can be still seen in advanced textview. this is ok and done
+ on purpose.
+ * MonoQuery/MonoQuery.mdp: Updated
+ * Mono.Data.Sql/Makefile.am:
+ * Mono.Data.Sql/Providers/FirebirdDbProvider.cs: New firebird
+ provider.
+ * Mono.Data.Sql/Providers/SybaseDbProvider.cs: New sybase provider
+ * Mono.Data.Sql/Providers/OdbcDbProvider.cs: New generic odbc
+ connector.
+ * Mono.Data.Sql/Mono.Data.Sql.mdp: Updated
+
2005-08-12 Lluis Sanchez Gual <lluis at novell.com>
* MonoQuery/Makefile.am: embed icons as resources.
Modified: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Makefile.am
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Makefile.am 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Makefile.am 2005-08-21 10:22:52 UTC (rev 2774)
@@ -29,6 +29,9 @@
Providers/NpgsqlDbProvider.cs \
Providers/SqliteDbProvider.cs \
Providers/OracleDbProvider.cs \
+Providers/FirebirdDbProvider.cs \
+Providers/OdbcDbProvider.cs \
+Providers/SybaseDbProvider.cs \
Providers/SqlDbProvider.cs \
AssemblyInfo.cs
@@ -39,7 +42,9 @@
-r:Npgsql \
-r:ByteFX.Data \
-r:Mono.Data.SqliteClient \
--r:System.Data.OracleClient
+-r:System.Data.OracleClient \
+-r:Mono.Data.SybaseClient \
+-r:$(top_srcdir)/contrib/FirebirdSql.Data.Firebird.dll
ADDIN_BUILD = $(top_builddir)/build/AddIns/MonoQuery
Modified: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Mono.Data.Sql.mdp
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Mono.Data.Sql.mdp 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Mono.Data.Sql.mdp 2005-08-21 10:22:52 UTC (rev 2774)
@@ -1,7 +1,7 @@
<Project name="Mono.Data.Sql" fileversion="2.0" language="C#" ctype="DotNetProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
- <Output directory="../bin/Debug" assembly="Mono.Data.Sql" />
+ <Output directory="./bin/Debug" assembly="Mono.Data.Sql" />
<Build debugmode="True" target="Library" />
<Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
<CodeGeneration compiler="Csc" warninglevel="1" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="True" ctype="CSharpCompilerParameters" />
@@ -49,6 +49,9 @@
<File name="./Providers/SqliteDbProvider.cs" subtype="Code" buildaction="Compile" />
<File name="./Providers/OracleDbProvider.cs" subtype="Code" buildaction="Compile" />
<File name="./Providers/SqlDbProvider.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Providers/FirebirdDbProvider.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Providers/OdbcDbProvider.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Providers/SybaseDbProvider.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="Npgsql, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
@@ -57,5 +60,7 @@
<ProjectReference type="Gac" localcopy="True" refto="Mono.Data.SqliteClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
<ProjectReference type="Gac" localcopy="True" refto="System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <ProjectReference type="Assembly" localcopy="True" refto="../../../contrib/FirebirdSql.Data.Firebird.dll" />
+ <ProjectReference type="Gac" localcopy="True" refto="Mono.Data.SybaseClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
</References>
</Project>
\ No newline at end of file
Added: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/FirebirdDbProvider.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/FirebirdDbProvider.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/FirebirdDbProvider.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -0,0 +1,456 @@
+//
+// Provider/FirebirdDbProvider.cs
+//
+// Authors:
+// Christian Hergert <chris at mosaix.net>
+// Daniel Morgan <danielmorgan at verizon.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (C) 2005 Daniel Morgan
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Data;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using FirebirdSql.Data.Firebird;
+
+namespace Mono.Data.Sql
+{
+ /// <summary>
+ /// Mono.Data.Sql provider for PostgreSQL databases.
+ /// </summary>
+ [Serializable]
+ public class FirebirdDbProvider : DbProviderBase
+ {
+ protected FbConnection connection = null;
+ protected FbDataAdapter adapter = new FbDataAdapter();
+ protected bool isConnectionStringWrong = false;
+
+ /// <summary>
+ /// Default Constructor
+ /// </summary>
+ public FirebirdDbProvider () : base ()
+ {
+ }
+
+ public override string ProviderName {
+ get {
+ return "Firebird Database";
+ }
+ }
+
+ /// <summary>
+ /// Constructor with ADO.NET Npgsql connection.
+ /// </summary>
+ public FirebirdDbProvider (FbConnection conn)
+ {
+ connection = conn;
+ }
+
+ /// <summary>
+ /// ADO.NET Connection
+ /// </summary>
+ public override IDbConnection Connection {
+ get {
+ if (connection == null)
+ connection = new FbConnection();
+
+ return (IDbConnection) connection;
+ }
+ }
+
+ /// <summary>
+ /// Connection String
+ /// </summary>
+ public override string ConnectionString {
+ get {
+ return Connection.ConnectionString;
+ }
+ set {
+ if (IsOpen == true)
+ Close();
+
+ Connection.ConnectionString = value;
+ isConnectionStringWrong = false;
+ }
+ }
+
+ /// <summary>
+ /// Is the connection open
+ /// </summary>
+ public override bool IsOpen {
+ get {
+ return Connection.State == ConnectionState.Open;
+ }
+ }
+
+ /// <summary>
+ /// Is the last used connection string wrong
+ /// </summary>
+ public override bool IsConnectionStringWrong {
+ get {
+ return isConnectionStringWrong;
+ }
+ }
+
+ /// <summary>
+ /// Open the connection. Returns true on success.
+ /// </summary>
+ public override bool Open()
+ {
+ try {
+ Connection.Open();
+ } catch {
+ isConnectionStringWrong = true;
+ }
+ OnOpen ();
+ return IsOpen;
+ }
+
+ /// <summary>
+ /// Close the database connection.
+ /// </summary>
+ public override void Close()
+ {
+ Connection.Close();
+ OnClose();
+ }
+
+ /// <summary>
+ /// Do we support the passed schema type
+ /// </summary>
+ public override bool SupportsSchemaType(Type type)
+ {
+ if (type == typeof(TableSchema))
+ return true;
+ else if (type == typeof(ViewSchema))
+ return true;
+ else if (type == typeof(ProcedureSchema))
+ return true;
+ else if (type == typeof(AggregateSchema))
+ return true;
+ else if (type == typeof(GroupSchema))
+ return true;
+ else if (type == typeof(UserSchema))
+ return true;
+ else if (type == typeof(LanguageSchema))
+ return true;
+ else if (type == typeof(OperatorSchema))
+ return true;
+ else if (type == typeof(RoleSchema))
+ return true;
+ else if (type == typeof(SequenceSchema))
+ return true;
+ else if (type == typeof(DataTypeSchema))
+ return true;
+ else if (type == typeof(TriggerSchema))
+ return true;
+ else if (type == typeof(ColumnSchema))
+ return true;
+ else if (type == typeof(ConstraintSchema))
+ return true;
+ else if (type == typeof(RuleSchema))
+ return true;
+ else
+ return false;
+ }
+
+ /// <summary>
+ /// Thread safe SQL execution.
+ /// </summary>
+ public override DataTable ExecuteSQL(string SQLText)
+ {
+ FbCommand command = new FbCommand();
+ command.Connection = connection;
+ command.CommandText = SQLText;
+
+ DataSet resultSet = new DataSet ();
+
+ lock(adapter) {
+ adapter.SelectCommand = command;
+ adapter.Fill(resultSet);
+ }
+
+ return resultSet.Tables[0];
+ }
+
+ /// <summary>
+ /// Get a list of tables in the system.
+ /// </summary>
+ public override TableSchema[] GetTables()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ DataTable dataTable = connection.GetSchema ("Tables", new string[] {null, null, null, "TABLE"});
+
+ for (int r = 0; r < dataTable.Rows.Count; r++) {
+ DataRow row = dataTable.Rows[r];
+ string tableName = row["TABLE_NAME"].ToString();
+
+ TableSchema table = new TableSchema();
+ table.Provider = this;
+ table.Name = tableName;
+ table.IsSystemTable = false; // TODO
+
+ table.SchemaName = String.Empty;
+ table.OwnerName = String.Empty;
+ table.Comment = String.Empty;
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat ("-- Table: {0}\n", table.Name);
+ sb.AppendFormat ("-- DROP TABLE {0};\n\n", table.Name);
+ sb.AppendFormat ("CREATE TABLE {0} (\n", table.Name);
+
+ ColumnSchema[] columns = table.Columns;
+ string[] parts = new string[columns.Length];
+ for (int i = 0; i < parts.Length; i++) {
+ parts[i] = "\t" + columns[i].Definition;
+ }
+ sb.Append (String.Join (",\n", parts));
+
+ //ConstraintSchema[] cons = table.Constraints;
+ /*
+ parts = new string[cons.Length];
+ if (cons.Length > 0)
+ sb.Append (",\n");
+ for (int i = 0; i < parts.Length; i++) {
+ parts[i] = "\t" + cons[i].Definition;
+ }
+ sb.Append (String.Join (",\n", parts));
+ */
+
+ sb.Append ("\n);\n");
+ //sb.AppendFormat ("COMMENT ON TABLE {0} IS '{1}';", table.Name, table.Comment);
+ table.Definition = sb.ToString();
+ collection.Add (table);
+
+ }
+
+ return (TableSchema[]) collection.ToArray (typeof (TableSchema));
+ }
+
+ /// <summary>
+ /// Get columns for a table.
+ /// </summary>
+ public override ColumnSchema[] GetTableColumns(TableSchema table)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList();
+
+ DataTable table2 = connection.GetSchema ("Columns", new string[] {null, null, table.Name, null});
+ for (int r = 0; r < table2.Rows.Count; r++) {
+ DataRow row2 = table2.Rows[r];
+
+ string columnName = row2["COLUMN_NAME"].ToString();
+ string dataType = row2["COLUMN_DATA_TYPE"].ToString();
+
+ int columnSize = 0;
+ if (row2["COLUMN_SIZE"] != DBNull.Value)
+ columnSize = (int) row2["COLUMN_SIZE"];
+
+ int precision = 0;
+ if (row2["NUMERIC_PRECISION"] != DBNull.Value)
+ precision = (int) row2["NUMERIC_PRECISION"];
+
+ int scale = 0;
+ if (row2["NUMERIC_SCALE"] != DBNull.Value)
+ scale = (int) row2["NUMERIC_SCALE"];
+
+ //bool isNullable = false; // FIXME: is nullable
+ //short n = 0;
+ //if (row2["IS_NULLABLE"] != DBNull.Value)
+ // n = (short) row2["IS_NULLABLE"];
+ //
+ //if (n == 1)
+ // isNullable = true;
+
+ //int pos = 0; // FIXME: ordinal position
+ //if (row2["ORDINAL_POSITION"] != DBNull.Value)
+ // pos = (int) row2["ORDINAL_POSITION"];
+
+ ColumnSchema column = new ColumnSchema();
+
+ column.Name = columnName;
+ column.Provider = this;
+ column.DataTypeName = dataType;
+ column.Default = "";
+ column.Comment = "";
+ column.OwnerName = "";
+ column.SchemaName = table.SchemaName;
+ column.NotNull = false; // TODO
+ column.Length = columnSize;
+ column.Precision = precision;
+ column.Scale = scale;
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat("{0} {1}{2}",
+ column.Name,
+ column.DataTypeName,
+ (column.Length > 0) ? ("(" + column.Length + ")") : "");
+ sb.AppendFormat(" {0}", column.NotNull ? "NOT NULL" : "NULL");
+ if (column.Default.Length > 0)
+ sb.AppendFormat(" DEFAULT {0}", column.Default);
+ column.Definition = sb.ToString();
+
+ collection.Add(column);
+ }
+
+ return (ColumnSchema[]) collection.ToArray(typeof(ColumnSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of views from the system.
+ /// </summary>
+ public override ViewSchema[] GetViews()
+ {
+ ArrayList collection = new ArrayList();
+
+ DataTable table2 = connection.GetSchema ("Views", new string[] {null, null, null});
+ for (int r = 0; r < table2.Rows.Count; r++) {
+ DataRow row2 = table2.Rows[r];
+ string viewName = row2["VIEW_NAME"].ToString();
+
+ ViewSchema view = new ViewSchema();
+ view.Provider = this;
+
+ view.Name = viewName;
+ view.SchemaName = "";
+ view.OwnerName = "";
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat ("-- View: {0}\n", view.Name);
+ sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name);
+ sb.AppendFormat ("CREATE VIEW {0} AS (\n", view.Name);
+ view.Definition = "";
+
+ view.IsSystemView = false;
+ view.Comment = "";
+
+ collection.Add(view);
+ }
+
+ return (ViewSchema[]) collection.ToArray (typeof (ViewSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of columns within a view
+ /// </summary>
+ public override ColumnSchema[] GetViewColumns(ViewSchema view)
+ {
+ if (IsOpen == false && Open() == false)
+ throw new Exception ("No connection to database");
+
+ ArrayList collection = new ArrayList();
+
+ // TODO: get view columns
+
+ return (ColumnSchema[]) collection.ToArray (typeof(ColumnSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of constraints within a a table.
+ /// </summary>
+ public override ConstraintSchema[] GetTableConstraints (TableSchema table)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ // TODO: get constraints
+
+ return (ConstraintSchema[]) collection.ToArray (typeof(ConstraintSchema));
+ }
+
+ public override UserSchema[] GetUsers ()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ // TODO: get users
+
+ return (UserSchema[]) collection.ToArray (typeof (UserSchema));
+ }
+
+ public override ProcedureSchema[] GetProcedures ()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ DataTable table2 = null;
+ DataRow row2 = null;
+ table2 = connection.GetSchema ("Procedures", new string[] {null, null, null});
+ for (int r = 0; r < table2.Rows.Count; r++) {
+ row2 = table2.Rows[r];
+ ProcedureSchema procedure = new ProcedureSchema ();
+ procedure.Provider = this;
+ procedure.Name = row2["PROCEDURE_NAME"].ToString();
+ procedure.Definition = "";
+ procedure.LanguageName = "";
+ procedure.IsSystemProcedure = false;
+ collection.Add (procedure);
+ row2 = null;
+ }
+ table2 = null;
+
+ table2 = connection.GetSchema ("Functions", new string[] {null, null, null, null});
+ for (int r = 0; r < table2.Rows.Count; r++) {
+ row2 = table2.Rows[r];
+ ProcedureSchema procedure = new ProcedureSchema ();
+ procedure.Provider = this;
+ procedure.Name = row2["FUNCTION_NAME"].ToString();
+ procedure.Definition = "";
+ procedure.LanguageName = "";
+ procedure.IsSystemProcedure = false;
+ collection.Add (procedure);
+ row2 = null;
+ }
+ table2 = null;
+
+ return (ProcedureSchema[]) collection.ToArray (typeof (ProcedureSchema));
+ }
+
+ public override ColumnSchema[] GetProcedureColumns (ProcedureSchema schema)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ // TODO
+
+ return (ColumnSchema[]) collection.ToArray (typeof (ColumnSchema));
+ }
+ }
+}
Added: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/OdbcDbProvider.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/OdbcDbProvider.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/OdbcDbProvider.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -0,0 +1,295 @@
+//
+// Provider/OdbcDbProvider.cs
+//
+// Authors:
+// Christian Hergert <chris at mosaix.net>
+// Daniel Morgan <danielmorgan at verizon.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+// Copyright (C) 2005 Daniel Morgan
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Data;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using System.Data.Odbc;
+
+namespace Mono.Data.Sql
+{
+ /// <summary>
+ /// Mono.Data.Sql provider for PostgreSQL databases.
+ /// </summary>
+ [Serializable]
+ public class OdbcDbProvider : DbProviderBase
+ {
+ protected OdbcConnection connection = null;
+ protected OdbcDataAdapter adapter = new OdbcDataAdapter();
+ protected bool isConnectionStringWrong = false;
+
+ /// <summary>
+ /// Default Constructor
+ /// </summary>
+ public OdbcDbProvider () : base ()
+ {
+ }
+
+ public override string ProviderName {
+ get {
+ return "Provider for ODBC Data Sources";
+ }
+ }
+
+ /// <summary>
+ /// Constructor with ADO.NET ODBC connection.
+ /// </summary>
+ public OdbcDbProvider (OdbcConnection conn)
+ {
+ connection = conn;
+ }
+
+ /// <summary>
+ /// ADO.NET Connection
+ /// </summary>
+ public override IDbConnection Connection {
+ get {
+ if (connection == null)
+ connection = new OdbcConnection();
+
+ return (IDbConnection) connection;
+ }
+ }
+
+ /// <summary>
+ /// Connection String
+ /// </summary>
+ public override string ConnectionString {
+ get {
+ return Connection.ConnectionString;
+ }
+ set {
+ if (IsOpen == true)
+ Close();
+
+ Connection.ConnectionString = value;
+ isConnectionStringWrong = false;
+ }
+ }
+
+ /// <summary>
+ /// Is the connection open
+ /// </summary>
+ public override bool IsOpen {
+ get {
+ return Connection.State == ConnectionState.Open;
+ }
+ }
+
+ /// <summary>
+ /// Is the last used connection string wrong
+ /// </summary>
+ public override bool IsConnectionStringWrong {
+ get {
+ return isConnectionStringWrong;
+ }
+ }
+
+ /// <summary>
+ /// Open the connection. Returns true on success.
+ /// </summary>
+ public override bool Open()
+ {
+ try {
+ Connection.Open();
+ } catch {
+ isConnectionStringWrong = true;
+ }
+ OnOpen ();
+ return IsOpen;
+ }
+
+ /// <summary>
+ /// Close the database connection.
+ /// </summary>
+ public override void Close()
+ {
+ Connection.Close();
+ OnClose();
+ }
+
+ /// <summary>
+ /// Do we support the passed schema type
+ /// </summary>
+ public override bool SupportsSchemaType(Type type)
+ {
+ if (type == typeof(TableSchema))
+ return true;
+ else if (type == typeof(ViewSchema))
+ return true;
+ else if (type == typeof(ProcedureSchema))
+ return true;
+ else if (type == typeof(AggregateSchema))
+ return true;
+ else if (type == typeof(GroupSchema))
+ return true;
+ else if (type == typeof(UserSchema))
+ return true;
+ else if (type == typeof(LanguageSchema))
+ return true;
+ else if (type == typeof(OperatorSchema))
+ return true;
+ else if (type == typeof(RoleSchema))
+ return true;
+ else if (type == typeof(SequenceSchema))
+ return true;
+ else if (type == typeof(DataTypeSchema))
+ return true;
+ else if (type == typeof(TriggerSchema))
+ return true;
+ else if (type == typeof(ColumnSchema))
+ return true;
+ else if (type == typeof(ConstraintSchema))
+ return true;
+ else if (type == typeof(RuleSchema))
+ return true;
+ else
+ return false;
+ }
+
+ /// <summary>
+ /// Thread safe SQL execution.
+ /// </summary>
+ public override DataTable ExecuteSQL(string SQLText)
+ {
+ OdbcCommand command = new OdbcCommand();
+ command.Connection = connection;
+ command.CommandText = SQLText;
+
+ DataSet resultSet = new DataSet ();
+
+ lock(adapter) {
+ adapter.SelectCommand = command;
+ adapter.Fill(resultSet);
+ }
+
+ return resultSet.Tables[0];
+ }
+
+ /// <summary>
+ /// Get a list of tables in the system.
+ /// </summary>
+ public override TableSchema[] GetTables()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+ // TODO:
+ return (TableSchema[]) collection.ToArray (typeof (TableSchema));
+ }
+
+ /// <summary>
+ /// Get columns for a table.
+ /// </summary>
+ public override ColumnSchema[] GetTableColumns(TableSchema table)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList();
+ // TODO:
+ return (ColumnSchema[]) collection.ToArray(typeof(ColumnSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of views from the system.
+ /// </summary>
+ public override ViewSchema[] GetViews()
+ {
+ ArrayList collection = new ArrayList();
+ // TODO:
+ return (ViewSchema[]) collection.ToArray (typeof (ViewSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of columns within a view
+ /// </summary>
+ public override ColumnSchema[] GetViewColumns(ViewSchema view)
+ {
+ if (IsOpen == false && Open() == false)
+ throw new Exception ("No connection to database");
+
+ ArrayList collection = new ArrayList();
+ // TODO:
+
+ return (ColumnSchema[]) collection.ToArray (typeof(ColumnSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of constraints within a a table.
+ /// </summary>
+ public override ConstraintSchema[] GetTableConstraints (TableSchema table)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+ // TODO:
+
+ return (ConstraintSchema[]) collection.ToArray (typeof(ConstraintSchema));
+ }
+
+ public override UserSchema[] GetUsers ()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+ // TODO:
+ return (UserSchema[]) collection.ToArray (typeof (UserSchema));
+ }
+
+ public override ProcedureSchema[] GetProcedures ()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ // TODO:
+ return (ProcedureSchema[]) collection.ToArray (typeof (ProcedureSchema));
+ }
+
+ public override ColumnSchema[] GetProcedureColumns (ProcedureSchema schema)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+ // TODO:
+ return (ColumnSchema[]) collection.ToArray (typeof (ColumnSchema));
+ }
+ }
+}
+
Added: trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/SybaseDbProvider.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/SybaseDbProvider.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/Mono.Data.Sql/Providers/SybaseDbProvider.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -0,0 +1,471 @@
+//
+// Provider/SybaseDbProvider.cs
+//
+// Authors:
+// Christian Hergert <chris at mosaix.net>
+// Daniel Morgan <danielmorgan at verizon.net>
+//
+// Copyright (C) 2005 Mosaix Communications, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Data;
+using System.Text;
+using System.Text.RegularExpressions;
+
+using Mono.Data.SybaseClient;
+
+namespace Mono.Data.Sql
+{
+ /// <summary>
+ /// Mono.Data.Sql provider for PostgreSQL databases.
+ /// </summary>
+ [Serializable]
+ public class SybaseDbProvider : DbProviderBase
+ {
+ protected SybaseConnection connection = null;
+ protected SybaseDataAdapter adapter = new SybaseDataAdapter();
+ protected bool isConnectionStringWrong = false;
+
+ /// <summary>
+ /// Default Constructor
+ /// </summary>
+ public SybaseDbProvider () : base ()
+ {
+ }
+
+ public override string ProviderName {
+ get {
+ return "Sybase ASE Database";
+ }
+ }
+
+ /// <summary>
+ /// Constructor with ADO.NET Sql connection.
+ /// </summary>
+ public SybaseDbProvider (SybaseConnection conn)
+ {
+ connection = conn;
+ }
+
+ /// <summary>
+ /// ADO.NET Connection
+ /// </summary>
+ public override IDbConnection Connection {
+ get {
+ if (connection == null)
+ connection = new SybaseConnection();
+
+ return (IDbConnection) connection;
+ }
+ }
+
+ /// <summary>
+ /// Connection String
+ /// </summary>
+ public override string ConnectionString {
+ get {
+ return Connection.ConnectionString;
+ }
+ set {
+ if (IsOpen == true)
+ Close();
+
+ Connection.ConnectionString = value;
+ isConnectionStringWrong = false;
+ }
+ }
+
+ /// <summary>
+ /// Is the connection open
+ /// </summary>
+ public override bool IsOpen {
+ get {
+ return Connection.State == ConnectionState.Open;
+ }
+ }
+
+ /// <summary>
+ /// Is the last used connection string wrong
+ /// </summary>
+ public override bool IsConnectionStringWrong {
+ get {
+ return isConnectionStringWrong;
+ }
+ }
+
+ /// <summary>
+ /// Open the connection. Returns true on success.
+ /// </summary>
+ public override bool Open()
+ {
+ try {
+ Connection.Open();
+ } catch {
+ isConnectionStringWrong = true;
+ }
+ OnOpen ();
+ return IsOpen;
+ }
+
+ /// <summary>
+ /// Close the database connection.
+ /// </summary>
+ public override void Close()
+ {
+ Connection.Close();
+ OnClose();
+ }
+
+ /// <summary>
+ /// Do we support the passed schema type
+ /// </summary>
+ public override bool SupportsSchemaType(Type type)
+ {
+ if (type == typeof(TableSchema))
+ return true;
+ else if (type == typeof(ViewSchema))
+ return true;
+ else if (type == typeof(ProcedureSchema))
+ return true;
+ else if (type == typeof(AggregateSchema))
+ return true;
+ else if (type == typeof(GroupSchema))
+ return true;
+ else if (type == typeof(UserSchema))
+ return true;
+ else if (type == typeof(LanguageSchema))
+ return true;
+ else if (type == typeof(OperatorSchema))
+ return true;
+ else if (type == typeof(RoleSchema))
+ return true;
+ else if (type == typeof(SequenceSchema))
+ return true;
+ else if (type == typeof(DataTypeSchema))
+ return true;
+ else if (type == typeof(TriggerSchema))
+ return true;
+ else if (type == typeof(RuleSchema))
+ return true;
+ else
+ return false;
+ }
+
+ /// <summary>
+ /// Thread safe SQL execution.
+ /// </summary>
+ public override DataTable ExecuteSQL(string SQLText)
+ {
+ SybaseCommand command = new SybaseCommand();
+ command.Connection = connection;
+ command.CommandText = SQLText;
+
+ DataSet resultSet = new DataSet ();
+
+ lock(adapter) {
+ adapter.SelectCommand = command;
+ adapter.Fill(resultSet);
+ }
+
+ return resultSet.Tables[0];
+ }
+
+ /// <summary>
+ /// Get a list of tables in the system.
+ /// </summary>
+ public override TableSchema[] GetTables()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ SybaseCommand command = new SybaseCommand();
+ command.Connection = connection;
+ command.CommandText =
+ "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
+ " so.crdate as created_date, so.type as table_type " +
+ "FROM dbo.sysobjects so, dbo.sysusers su " +
+ "WHERE type IN ('S','U') " +
+ "AND su.uid = so.uid " +
+ "ORDER BY 1, 2";
+ SybaseDataReader r = command.ExecuteReader();
+
+ while (r.Read()) {
+ TableSchema table = new TableSchema();
+ table.Provider = this;
+ table.Name = r.GetString(1);
+
+ table.IsSystemTable = r.GetString(4) == "S" ? true : false;
+
+ table.SchemaName = r.GetString(0);
+ table.OwnerName = r.GetString(0);
+ table.Comment = "";
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat ("-- Table: {0}\n", table.Name);
+ sb.AppendFormat ("-- DROP TABLE {0};\n\n", table.Name);
+ sb.AppendFormat ("CREATE TABLE {0} (\n", table.Name);
+
+ ColumnSchema[] columns = table.Columns;
+ string[] parts = new string[columns.Length];
+ for (int i = 0; i < parts.Length; i++) {
+ parts[i] = "\t" + columns[i].Definition;
+ }
+ sb.Append (String.Join (",\n", parts));
+
+ ConstraintSchema[] cons = table.Constraints;
+ parts = new string[cons.Length];
+ if (cons.Length > 0)
+ sb.Append (",\n");
+ for (int i = 0; i < parts.Length; i++) {
+ parts[i] = "\t" + cons[i].Definition;
+ }
+ sb.Append (String.Join (",\n", parts));
+
+ sb.Append ("\n);\n");
+ //sb.AppendFormat ("COMMENT ON TABLE {0} IS '{1}';", table.Name, table.Comment);
+ table.Definition = sb.ToString();
+ collection.Add (table);
+ }
+ r.Close ();
+ r = null;
+ command.Dispose ();
+ command = null;
+
+ return (TableSchema[]) collection.ToArray (typeof (TableSchema));
+ }
+
+ /// <summary>
+ /// Get columns for a table.
+ /// </summary>
+ public override ColumnSchema[] GetTableColumns(TableSchema table)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList();
+ SybaseConnection con2 = (SybaseConnection) (((ICloneable) connection).Clone ());
+ if (con2.State == ConnectionState.Closed)
+ con2.Open();
+ SybaseCommand command = con2.CreateCommand ();
+
+ command.CommandText =
+ "select su.name as owner, so.name as table_name, sc.name as column_name, " +
+ " st.name as date_type, sc.length as column_length, " +
+ " sc.prec as data_preceision, sc.scale as data_scale, " +
+ " 0 as isnullable, sc.colid as column_id " +
+ "from dbo.syscolumns sc, dbo.sysobjects so, " +
+ " dbo.systypes st, dbo.sysusers su " +
+ "where sc.id = so.id " +
+ "and so.type in ('U','S') " +
+ "and so.name = '" + table.Name + "' " +
+ "and su.name = '" + table.OwnerName + "' " +
+ "and su.uid = so.uid " +
+ "and sc.usertype = st.usertype " +
+ "order by sc.colid";
+
+ SybaseDataReader r = command.ExecuteReader();
+
+ while (r.Read()) {
+ ColumnSchema column = new ColumnSchema();
+
+ try { column.Name = r.GetString(2); } catch {}
+ column.Provider = this;
+ try { column.DataTypeName = r.GetString(3); } catch {}
+ try { column.Default = ""; } catch {}
+ column.Comment = "";
+ column.OwnerName = table.OwnerName;
+ column.SchemaName = table.OwnerName;
+ try { column.NotNull = r.GetValue(7).ToString() == "0" ? true : false; } catch {}
+ try { column.Length = r.GetInt32(4); } catch {}
+ //try { column.Precision = GetInt(r, 5)); } catch {}
+ //try { column.Scale = GetIn(r, 6); } catch {}
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat("{0} {1}{2}",
+ column.Name,
+ column.DataTypeName,
+ (column.Length > 0) ? ("(" + column.Length + ")") : "");
+ sb.AppendFormat(" {0}", column.NotNull ? "NOT NULL" : "NULL");
+ //if (column.Default.Length > 0)
+ // sb.AppendFormat(" DEFAULT {0}", column.Default);
+ column.Definition = sb.ToString();
+
+ collection.Add(column);
+ }
+ r.Close ();
+ r = null;
+ command.Dispose ();
+ command = null;
+ con2.Close ();
+ con2 = null;
+
+ return (ColumnSchema[]) collection.ToArray(typeof(ColumnSchema));
+ }
+
+ private string GetSource (string objectName)
+ {
+ string sql = String.Format ("EXEC [master].[dbo].[sp_helptext] '{0}', null", objectName);
+ SybaseConnection con2 = (SybaseConnection) (((ICloneable) connection).Clone ());
+ if (con2.State == ConnectionState.Closed)
+ con2.Open();
+ SybaseCommand cmd = con2.CreateCommand ();
+ cmd.CommandText = sql;
+ IDataReader reader = cmd.ExecuteReader ();
+
+ StringBuilder sb = new StringBuilder ();
+
+ while (reader.Read ()) {
+ string text = reader.GetString (0);
+ sb.Append (text);
+ }
+
+ reader.Close ();
+ reader = null;
+ cmd.Dispose ();
+ cmd = null;
+ con2.Close ();
+ con2 = null;
+
+ return sb.ToString ();
+ }
+
+ /// <summary>
+ /// Get a collection of views from the system.
+ /// </summary>
+ public override ViewSchema[] GetViews()
+ {
+ ArrayList collection = new ArrayList();
+
+ SybaseCommand command = new SybaseCommand();
+ command.Connection = connection;
+ command.CommandText =
+ "SELECT su.name AS owner, so.name as table_name, so.id as table_id, " +
+ " so.crdate as created_date, so.type as table_type " +
+ "FROM dbo.sysobjects so, dbo.sysusers su " +
+ "WHERE type = 'V' " +
+ "AND su.uid = so.uid " +
+ "ORDER BY 1, 2";
+ SybaseDataReader r = command.ExecuteReader();
+
+ while (r.Read()) {
+ ViewSchema view = new ViewSchema();
+ view.Provider = this;
+
+ try {
+ view.Name = r.GetString(1);
+ view.SchemaName = r.GetString(0);
+ view.OwnerName = r.GetString(0);
+
+ StringBuilder sb = new StringBuilder();
+ sb.AppendFormat ("-- View: {0}\n", view.Name);
+ sb.AppendFormat ("-- DROP VIEW {0};\n\n", view.Name);
+ string source = GetSource(view.Owner + "." + view.Name);
+ sb.AppendFormat (" {0}\n);", source);
+ view.Definition = sb.ToString ();
+ //view.Comment = r.GetString(5);
+ } catch (Exception e) {
+ }
+
+ collection.Add(view);
+ }
+ r.Close ();
+ r = null;
+ command.Dispose();
+ command = null;
+
+ return (ViewSchema[]) collection.ToArray (typeof (ViewSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of columns within a view
+ /// </summary>
+ public override ColumnSchema[] GetViewColumns(ViewSchema view)
+ {
+ if (IsOpen == false && Open() == false)
+ throw new Exception ("No connection to database");
+
+ ArrayList collection = new ArrayList();
+
+ SybaseConnection con2 = (SybaseConnection) (((ICloneable) connection).Clone ());
+ if (con2.State == ConnectionState.Closed)
+ con2.Open();
+ SybaseCommand command = con2.CreateCommand ();
+ command.CommandText =
+ "SELECT * " +
+ " FROM " + view.Name +
+ " WHERE 1 = 0";
+ SybaseDataReader r = command.ExecuteReader();
+
+ for (int i = 0; i < r.FieldCount; i++) {
+ ColumnSchema column = new ColumnSchema();
+
+ column.Name = r.GetName(i);
+ column.DataTypeName = r.GetDataTypeName(i);
+ column.Default = "";
+ column.Definition = "";
+ column.OwnerName = view.OwnerName;
+ column.SchemaName = view.OwnerName;
+
+ collection.Add(column);
+ }
+
+ command.Dispose ();
+ command = null;
+ con2.Close ();
+ con2 = null;
+
+ return (ColumnSchema[]) collection.ToArray (typeof(ColumnSchema));
+ }
+
+ /// <summary>
+ /// Get a collection of constraints within a a table.
+ /// </summary>
+ public override ConstraintSchema[] GetTableConstraints (TableSchema table)
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+// ArrayList collection = new ArrayList ();
+//
+// SybaseConnection con2 = (SybaseConnection) (((ICloneable) connection).Clone ());
+// con2.Open();
+// SybaseCommand command = con2.CreateCommand ();
+
+ // TODO: get constraints
+ return new ConstraintSchema[0];
+ }
+
+ public override UserSchema[] GetUsers ()
+ {
+ if (IsOpen == false && Open () == false)
+ throw new InvalidOperationException ("Invalid connection");
+
+ ArrayList collection = new ArrayList ();
+
+ return (UserSchema[]) collection.ToArray (typeof (UserSchema));
+ }
+ }
+}
Modified: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/DbProviderCollection.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/DbProviderCollection.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/DbProviderCollection.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -40,6 +40,9 @@
[XmlInclude (typeof (SqliteDbProvider))]
[XmlInclude (typeof (OracleDbProvider))]
[XmlInclude (typeof (SqlDbProvider))]
+ [XmlInclude (typeof (FirebirdDbProvider))]
+ [XmlInclude (typeof (SybaseDbProvider))]
+ [XmlInclude (typeof (OdbcDbProvider))]
public class DbProviderCollection : CollectionBase
{
public DbProviderCollection () : base ()
Modified: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/Gui/NodeBuilders/TableNodeBuilder.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -115,7 +115,7 @@
public override void ActivateItem ()
{
TableSchema table = CurrentNode.DataItem as TableSchema;
- string query = String.Format ("SELECT * FROM {0};", table.Name);
+ string query = String.Format ("SELECT * FROM {0}", table.Name);
table.Provider.ExecuteSQL (query, (SQLCallback) Runtime.DispatchService.GuiDispatch (new SQLCallback (ActivateSQLCallback)));
}
Modified: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/MonoQuery.mdp
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/MonoQuery.mdp 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/MonoQuery.mdp 2005-08-21 10:22:52 UTC (rev 2774)
@@ -60,11 +60,11 @@
<ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
- <ProjectReference type="Gac" localcopy="True" refto="MonoDevelop.Base, Version=0.7.0.0, Culture=neutral" />
- <ProjectReference type="Gac" localcopy="True" refto="MonoDevelop.Core, Version=0.7.0.0, Culture=neutral" />
- <ProjectReference type="Gac" localcopy="True" refto="MonoDevelop.Gui.Widgets, Version=0.7.0.0, Culture=neutral" />
<ProjectReference type="Gac" localcopy="True" refto="gtksourceview-sharp, Version=1.0.0.2, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="glade-sharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ <ProjectReference type="Assembly" localcopy="True" refto="../../../build/bin/MonoDevelop.Base.dll" />
+ <ProjectReference type="Assembly" localcopy="True" refto="../../../build/bin/MonoDevelop.Core.dll" />
+ <ProjectReference type="Assembly" localcopy="True" refto="../../../build/bin/MonoDevelop.Gui.Widgets.dll" />
</References>
</Project>
\ No newline at end of file
Modified: trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/monoquery.glade
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/monoquery.glade 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/MonoQuery/monoquery.glade 2005-08-21 10:22:52 UTC (rev 2774)
@@ -389,7 +389,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
- <property name="visibility">True</property>
+ <property name="visibility">False</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
Added: trunk/MonoDevelop/Extras/MonoQuery/tests/test-firebird-1.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/tests/test-firebird-1.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/tests/test-firebird-1.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -0,0 +1,99 @@
+// test-firebird-1.cs
+//
+// $ mcs test-firebird-1.cs /r:System.Data /r:FirebirdSql.Data.Firebird /r:Mono.Data.Sql
+//
+
+using System;
+using System.Data;
+using FirebirdSql.Data.Firebird;
+using System.Text;
+using Mono.Data.Sql;
+
+namespace Mono.Data.Sql.Tests
+{
+ public class CreateProviderTest
+ {
+ static FirebirdDbProvider provider = null;
+
+ static TableSchema[] tables = null;
+ static ViewSchema[] views = null;
+
+ public static void Main(string[] args)
+ {
+ Console.WriteLine("Test Firebird Meta Data Provider...");
+
+ provider = new FirebirdDbProvider ();
+ provider.ConnectionString = @"Database=D:\PROGRA~1\Firebird\Firebird_1_5\examples\EMPLOYEE.FDB;User=SYSDBA;Password=masterkey;Dialect=3;Server=localhost";
+
+ Console.WriteLine("Opening database...");
+ provider.Open ();
+
+ Console.WriteLine("Do tests...");
+
+ ListTables ();
+ ListViews ();
+
+ tables = null;
+ views = null;
+
+ Console.WriteLine("Close provider...");
+
+ provider.Close();
+
+ Console.WriteLine("Test Done.");
+ }
+
+ public static void ListTables ()
+ {
+ Console.WriteLine("List Tables...");
+ tables = provider.GetTables ();
+ Console.WriteLine("Tables Found: {0}", tables.Length);
+
+ for (int i = 0; i < tables.Length; i++) {
+ TableSchema table = tables[i];
+ Console.WriteLine(" Table{0} Owner: {1} Name: {2} ",
+ i, table.OwnerName, table.Name);
+ if (i == 0)
+ ListTableColumns(table);
+ }
+ }
+
+ public static void ListTableColumns (TableSchema table)
+ {
+ ColumnSchema[] columns = table.Columns;
+
+ for (int c = 0; c < columns.Length; c++) {
+ ColumnSchema column = columns[c];
+ Console.WriteLine("Column{0}: ", c);
+ Console.WriteLine(" Name: {0}", column.Name);
+ Console.WriteLine(" DataTypeName: {0}", column.DataTypeName);
+ Console.WriteLine(" Length: {0}", column.Length);
+ //Console.WriteLine(" Precision: {0}", column.Precision);
+ //Console.WriteLine(" Scale: {0}", column.Scale);
+ //Console.WriteLine(" NotNull: {0}", column.NotNull);
+ Console.WriteLine("");
+ }
+ }
+
+ public static void ListViews ()
+ {
+ Console.WriteLine("List Views...");
+
+ views = provider.GetViews ();
+ for (int v = 0; v < views.Length; v++) {
+ ViewSchema view = views[v];
+ Console.WriteLine("View{0}: " ,v);
+ Console.WriteLine(" Name: {0}", view.Name);
+ Console.WriteLine(" Owner: {0}", view.OwnerName);
+ if (v == 0)
+ ListView (view);
+ }
+ }
+
+ public static void ListView (ViewSchema view)
+ {
+ Console.WriteLine("View Definition:\n" + view.Definition);
+ }
+ }
+}
+
Added: trunk/MonoDevelop/Extras/MonoQuery/tests/test-oracle-1.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/tests/test-oracle-1.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/tests/test-oracle-1.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -0,0 +1,93 @@
+// test-oracle-1.cs
+//
+// $ mcs test-oracle-1.cs /r:System.Data /r:System.Data.OracleClient /r:Mono.Data.Sql
+//
+
+using System;
+using System.Data;
+using System.Data.OracleClient;
+using System.Text;
+using Mono.Data.Sql;
+
+namespace Mono.Data.Sql.Tests
+{
+ public class CreateProviderTest
+ {
+ static OracleDbProvider provider = null;
+
+ static TableSchema[] tables = null;
+ static ViewSchema[] views = null;
+
+ public static void Main(string[] args)
+ {
+ Console.WriteLine("Test Oracle Meta Data Provider...");
+
+ provider = new OracleDbProvider ();
+ provider.ConnectionString = "Data Source=palis;user id=scott;password=tiger";
+ provider.Open ();
+
+ ListTables ();
+ ListViews ();
+
+ tables = null;
+ views = null;
+
+ provider.Close();
+
+ Console.WriteLine("Test Done.");
+ }
+
+ public static void ListTables ()
+ {
+ Console.WriteLine("List Tables...");
+ tables = provider.GetTables ();
+ Console.WriteLine("Tables Found: {0}", tables.Length);
+
+ for (int i = 0; i < tables.Length; i++) {
+ TableSchema table = tables[i];
+ Console.WriteLine(" Table{0} Owner: {1} Name: {2} TableSpace: {3}",
+ i, table.OwnerName, table.Name, table.TableSpaceName);
+ if (i == 0)
+ ListTableColumns(table);
+ }
+ }
+
+ public static void ListTableColumns (TableSchema table)
+ {
+ ColumnSchema[] columns = table.Columns;
+
+ for (int c = 0; c < columns.Length; c++) {
+ ColumnSchema column = columns[c];
+ Console.WriteLine("Column{0}: ", c);
+ Console.WriteLine(" Name: {0}", column.Name);
+ Console.WriteLine(" DataTypeName: {0}", column.DataTypeName);
+ Console.WriteLine(" Length: {0}", column.Length);
+ Console.WriteLine(" Precision: {0}", column.Precision);
+ Console.WriteLine(" Scale: {0}", column.Scale);
+ Console.WriteLine(" NotNull: {0}", column.NotNull);
+ Console.WriteLine("");
+ }
+ }
+
+ public static void ListViews ()
+ {
+ Console.WriteLine("List Views...");
+
+ views = provider.GetViews ();
+ for (int v = 0; v < views.Length; v++) {
+ ViewSchema view = views[v];
+ Console.WriteLine("View{0}: " ,v);
+ Console.WriteLine(" Name: {0}", view.Name);
+ Console.WriteLine(" Owner: {0}", view.OwnerName);
+ if (v == 0)
+ ListView (view);
+ }
+ }
+
+ public static void ListView (ViewSchema view)
+ {
+ Console.WriteLine("View Definition:\n" + view.Definition);
+ }
+ }
+}
+
Added: trunk/MonoDevelop/Extras/MonoQuery/tests/test-sybase-1.cs
===================================================================
--- trunk/MonoDevelop/Extras/MonoQuery/tests/test-sybase-1.cs 2005-08-21 10:22:02 UTC (rev 2773)
+++ trunk/MonoDevelop/Extras/MonoQuery/tests/test-sybase-1.cs 2005-08-21 10:22:52 UTC (rev 2774)
@@ -0,0 +1,99 @@
+// test-sybase-1.cs
+//
+// $ mcs test-sybase-1.cs /r:System.Data /r:Mono.Data.SybaseClient /r:Mono.Data.Sql
+//
+
+using System;
+using System.Data;
+using Mono.Data.SybaseClient;
+using System.Text;
+using Mono.Data.Sql;
+
+namespace Mono.Data.Sql.Tests
+{
+ public class CreateProviderTest
+ {
+ static SybaseDbProvider provider = null;
+
+ static TableSchema[] tables = null;
+ static ViewSchema[] views = null;
+
+ public static void Main(string[] args)
+ {
+ Console.WriteLine("Test Sybase Meta Data Provider...");
+
+ provider = new SybaseDbProvider ();
+ provider.ConnectionString = "Server=DANPC,5000;Database=testdb;User ID=sa;Password=;";
+
+ Console.WriteLine("Opening database...");
+ provider.Open ();
+
+ Console.WriteLine("Do tests...");
+
+ ListTables ();
+ ListViews ();
+
+ tables = null;
+ views = null;
+
+ Console.WriteLine("Close provider...");
+
+ provider.Close();
+
+ Console.WriteLine("Test Done.");
+ }
+
+ public static void ListTables ()
+ {
+ Console.WriteLine("List Tables...");
+ tables = provider.GetTables ();
+ Console.WriteLine("Tables Found: {0}", tables.Length);
+
+ for (int i = 0; i < tables.Length; i++) {
+ TableSchema table = tables[i];
+ Console.WriteLine(" Table{0} Owner: {1} Name: {2} ",
+ i, table.OwnerName, table.Name);
+ if (i == 0)
+ ListTableColumns(table);
+ }
+ }
+
+ public static void ListTableColumns (TableSchema table)
+ {
+ ColumnSchema[] columns = table.Columns;
+
+ for (int c = 0; c < columns.Length; c++) {
+ ColumnSchema column = columns[c];
+ Console.WriteLine("Column{0}: ", c);
+ Console.WriteLine(" Name: {0}", column.Name);
+ Console.WriteLine(" DataTypeName: {0}", column.DataTypeName);
+ Console.WriteLine(" Length: {0}", column.Length);
+ //Console.WriteLine(" Precision: {0}", column.Precision);
+ //Console.WriteLine(" Scale: {0}", column.Scale);
+ //Console.WriteLine(" NotNull: {0}", column.NotNull);
+ Console.WriteLine("");
+ }
+ }
+
+ public static void ListViews ()
+ {
+ Console.WriteLine("List Views...");
+
+ views = provider.GetViews ();
+ for (int v = 0; v < views.Length; v++) {
+ ViewSchema view = views[v];
+ Console.WriteLine("View{0}: " ,v);
+ Console.WriteLine(" Name: {0}", view.Name);
+ Console.WriteLine(" Owner: {0}", view.OwnerName);
+ if (v == 0)
+ ListView (view);
+ }
+ }
+
+ public static void ListView (ViewSchema view)
+ {
+ Console.WriteLine("View Definition:\n" + view.Definition);
+ }
+ }
+}
+
More information about the Monodevelop-patches-list
mailing list