Beispiel #1
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            string db;
            string vers;

            using (DbCommand cmd = forDatabase.CreateCommand("SELECT sqlite_version()", CommandType.Text))
            {
                object versValue = forDatabase.ExecuteScalar(cmd);
                db   = cmd.Connection.Database;
                vers = (null == versValue) ? string.Empty : versValue.ToString();
            }

            string dbname = GetDataSourceNameFromConnection(forDatabase);
            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);

            DBDatabaseProperties props = new DBDatabaseProperties(dbname, "SQLite", db, "", "@{0}", new Version(vers),
                                                                  SupportedSchemaOptions.TablesViewsAndIndexes | DBSchemaTypes.CommandScripts, false,
                                                                  DBParameterLayout.Named, SUPPORTED_TYPES, new TopType[] { TopType.Count, TopType.Range },
                                                                  Schema.DBSchemaInformation.CreateDefault(),
                                                                  unsupported);

            return(props);
        }
Beispiel #2
0
        protected virtual bool TryGetProviderSpecificProperties(string provider, DBDatabase database, out DBDatabaseProperties props)
        {
            props = null;
            switch (provider.ToLower())
            {
            case ("microsoft.ace.oledb.12.0"):
                string datasource = GetDataSourceNameFromConnection(database, ';', '=', "data source");

                if (!string.IsNullOrEmpty(datasource))
                {
                    if (datasource.StartsWith("\""))
                    {
                        datasource = datasource.Substring(1, datasource.Length - 2);
                    }

                    datasource = System.IO.Path.GetFileNameWithoutExtension(datasource);
                }
                TypedOperationCollection unsupported = new TypedOperationCollection();
                this.FillNotSupported(unsupported);

                props = new DBDatabaseProperties(datasource, MSAccessProductName, "Microsoft", "OLEDB", "?", new Version("12.0"),
                                                 SupportedSchemaOptions.TablesViewsAndIndexes | DBSchemaTypes.StoredProcedure, false, DBParameterLayout.Positional,
                                                 SUPPORTED_ACCESS_TYPES, new TopType[] { TopType.Count },
                                                 Schema.DBSchemaInformation.CreateDefault(), unsupported);
                break;

            default:
                break;
            }
            return(props != null);
        }
Beispiel #3
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            string statement = "SELECT  SERVERPROPERTY('productversion') AS [version], SERVERPROPERTY ('productlevel') AS [level], SERVERPROPERTY ('edition') AS [edition]";
            DBDatabaseProperties props;

            System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder(forDatabase.ConnectionString);
            string dbname = builder.InitialCatalog;

            if (string.IsNullOrEmpty(dbname))
            {
                dbname = builder.DataSource;
            }


            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);

            DBSchemaInformation info = DBSchemaInformation.CreateDefault();

            TopType[] tops          = new TopType[] { TopType.Count, TopType.Percent, TopType.Range };
            bool      caseSensitive = false;
            string    level         = "?";
            string    edition       = "?";
            Version   version       = new Version(1, 0);

            forDatabase.ExecuteRead(statement, reader =>
            {
                if (reader.Read())
                {
                    level   = reader["level"].ToString();
                    edition = reader["edition"].ToString();
                    version = new Version(reader["version"].ToString());
                }
            });

            props = new DBDatabaseProperties(dbname, "SQL Server",
                                             level,
                                             edition,
                                             "@{0}",
                                             version,
                                             SupportedSchemaOptions.All,
                                             caseSensitive,
                                             DBParameterLayout.Named,
                                             SUPPORTED_TYPES, tops,
                                             info,
                                             unsupported);
            props.TemporaryTableConstruct = "";
            props.TemporaryTablePrefix    = "#";
            return(props);
        }
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            DBDatabaseProperties props = null;
            string vers;
            string edition = string.Empty;

            string db = this.GetDataSourceNameFromConnection(forDatabase, ';', '=', "Database");

            string versionFunction = "SELECT VERSION()";

            try
            {
                object value = forDatabase.ExecuteScalar(versionFunction, System.Data.CommandType.Text);
                vers = Convert.ToString(value);
                //format of the version is similar to '5.0.87-standard'
                if (string.IsNullOrEmpty(vers) == false)
                {
                    int index = vers.IndexOf('-');
                    if (index > -1)
                    {
                        edition = vers.Substring(index + 1).Trim();
                        vers    = vers.Substring(0, index - 1);
                    }
                }
                TypedOperationCollection unsupported = new TypedOperationCollection();


                props = new DBDatabaseProperties(db, "MySql",
                                                 string.Empty,
                                                 edition, "?{0}",
                                                 new Version(vers),
                                                 SupportedSchemaOptions.All,
                                                 false, DBParameterLayout.Named,
                                                 SUPPORTED_TYPES, SUPPORTED_TOPTYPES,
                                                 DBSchemaInformation.CreateDefault(),
                                                 unsupported
                                                 );
            }
            catch (Exception ex)
            {
                throw new System.Data.DataException(Errors.CannotGetPropertiesFromDB, ex);
            }
            return(props);
        }
Beispiel #5
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);

            DBSchemaInformation info = DBSchemaInformation.CreateDefault();

            TopType[] tops          = new TopType[] { TopType.Count, TopType.Percent, TopType.Range };
            bool      caseSensitive = false;
            string    level         = "?";
            string    edition       = "?";
            string    database      = "?";
            Version   version       = new Version(1, 0);

            string statement = "SELECT  SERVERPROPERTY('productversion') AS [version], SERVERPROPERTY ('productlevel') AS [level], SERVERPROPERTY ('edition') AS [edition], DB_NAME() As [currentdatabase]";

            forDatabase.ExecuteRead(statement, reader =>
            {
                if (reader.Read())
                {
                    level    = reader["level"].ToString();
                    edition  = reader["edition"].ToString();
                    version  = new Version(reader["version"].ToString());
                    database = reader["currentdatabase"].ToString();
                }
            });

            DBDatabaseProperties props = new DBDatabaseProperties(database, "SQL Server",
                                                                  level,
                                                                  edition,
                                                                  "?",
                                                                  version,
                                                                  SupportedSchemaOptions.All,
                                                                  caseSensitive,
                                                                  DBParameterLayout.Positional,
                                                                  SUPPORTED_TYPES, tops,
                                                                  info,
                                                                  unsupported);

            props.TemporaryTableConstruct = "";
            props.TemporaryTablePrefix    = "#";
            return(props);
        }
Beispiel #6
0
        protected override DBDatabaseProperties GetPropertiesFromDb(DBDatabase forDatabase)
        {
            string con = forDatabase.ConnectionString;
            //looking for 'Provider=Microsoft.ACE.OLEDB.12.0;'
            int    index    = con.IndexOf("Provider=");
            string provider = string.Empty;

            if (index > -1)
            {
                provider = con.Substring(index + "Provider=".Length);
                index    = provider.IndexOf(';');
                if (index > 0)
                {
                    provider = provider.Substring(0, index);
                }
                else
                {
                    provider = string.Empty;
                }
            }
            DBDatabaseProperties props;

            if (!string.IsNullOrEmpty(provider))
            {
                if (this.TryGetProviderSpecificProperties(provider, forDatabase, out props))
                {
                    return(props);
                }
            }

            TypedOperationCollection unsupported = new TypedOperationCollection();

            this.FillNotSupported(unsupported);
            string datasource = GetDataSourceNameFromConnection(forDatabase, ';', '=', "data source");

            props = new DBDatabaseProperties(datasource, "OleDb", "?", "?", "?{0}", new Version("0.0"),
                                             SupportedSchemaOptions.TablesViewsAndIndexes, false, DBParameterLayout.Positional,
                                             SUPPORTED_TYPES, new TopType[] { TopType.Count },
                                             DBSchemaInformation.CreateDefault(), unsupported);
            return(props);
        }
Beispiel #7
0
        public bool CheckConnection(out Exception failure)
        {
            bool success = false;

            failure = null;
            try
            {
                DBDatabase db = DBDatabase.Create(this.ConnectionString, this.ProviderName);

                //validate that we can get the properties and a schema provider
                DBDatabaseProperties    props = db.GetProperties();
                Schema.DBSchemaProvider prov  = db.GetSchemaProvider();
                Schema.DBSchemaMetaDataCollectionSet collections = prov.Collections;

                success = true;
            }
            catch (Exception ex)
            {
                success = false;
                failure = ex;
            }
            return(success);
        }
        //
        // ctor
        //


        #region .ctor(database, properties, writer, ownswriter)

        public DBMySqlStatementBuilder(DBDatabase database, DBDatabaseProperties properties, System.IO.TextWriter writer, bool ownsWriter)
            : base(database, properties, writer, ownsWriter)
        {
            _buildingsproc = false;
            _mysqldelim    = StdMySqlBlockDelimiter;
        }
Beispiel #9
0
 protected override DBSchemaProvider CreateSchemaProvider(DBDatabase forDatabase, DBDatabaseProperties properties)
 {
     if (null != properties && properties.ProductName == MSAccessProductName)
     {
         return(new DBMSAccessSchemaProvider(forDatabase, properties));
     }
     else
     {
         throw new NotSupportedException("The Schema provider is not supported for the product '" + properties.ProductName + "'");
     }
 }
Beispiel #10
0
 public DBOracleStatementBuilder(DBDatabase db, DBDatabaseProperties props,
                                 System.IO.TextWriter writer, bool ownsWriter)
     : base(db, props, writer, ownsWriter)
 {
 }
 public DBOleDbStatementBuilder(DBDatabase forDatabase, DBDatabaseProperties properties, System.IO.TextWriter tw, bool ownswriter)
     : base(forDatabase, properties, tw, ownswriter)
 {
 }
Beispiel #12
0
 protected override DBStatementBuilder CreateStatementBuilder(DBDatabase forDatabase, DBDatabaseProperties withProperties, System.IO.TextWriter writer, bool ownsWriter)
 {
     return(new DBOleDbStatementBuilder(forDatabase, withProperties, writer, ownsWriter));
 }
Beispiel #13
0
 protected override DBSchemaProvider CreateSchemaProvider(DBDatabase forDatabase, DBDatabaseProperties properties)
 {
     return(new DBSqLiteSchemaProvider(forDatabase, properties));
 }
Beispiel #14
0
 /// <summary>
 /// Creates a new instance of the DBMSAccessSchemaProvider
 /// </summary>
 /// <param name="database"></param>
 /// <param name="properties"></param>
 public DBMSAccessSchemaProvider(DBDatabase database, DBDatabaseProperties properties)
     : base(database, properties)
 {
 }
Beispiel #15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="forDatabase"></param>
 /// <param name="properties"></param>
 /// <param name="tw"></param>
 /// <param name="ownswriter"></param>
 internal protected DBSQLClientStatementBuilder(DBDatabase forDatabase, DBDatabaseProperties properties, System.IO.TextWriter tw, bool ownswriter)
     : base(forDatabase, properties, tw, ownswriter)
 {
 }
 public DBOracleSchemaProvider(DBDatabase database, DBDatabaseProperties properties)
     : base(database, properties)
 {
 }
Beispiel #17
0
        //
        // .ctor
        //

        #region public DBMySqlSchemaProvider(DBDatabase database, DBDatabaseProperties properties)

        public DBMySqlSchemaProvider(DBDatabase database, DBDatabaseProperties properties)
            : base(database, properties)
        {
        }
Beispiel #18
0
        //
        // .ctor
        //

        #region public DBSQLClientSchemaProvider(DBDatabase database, DBDatabaseProperties properties)

        /// <summary>
        /// Creates a new instance of the schema provider for an SqlClient database
        /// </summary>
        /// <param name="database"></param>
        /// <param name="properties"></param>
        public DBSQLClientSchemaProvider(DBDatabase database, DBDatabaseProperties properties)
            : base(database, properties)
        {
        }
Beispiel #19
0
        //
        // .ctor
        //

        internal DBSqLiteSchemaProvider(DBDatabase forDatabase, DBDatabaseProperties properties)
            : base(forDatabase, properties)
        {
        }