Пример #1
0
        //----------------------------------------------------------------
        #region ** implementation

        void GetSchema()
        {
            // translate ODBC requests into OleDb
            string connString = OleDbConnString.TranslateConnectionString(_connString);

            // initialize this DataSet
            this.Reset();

            // go get the schema
            EnforceConstraints = false;
            using (var conn = new OleDbConnection(connString))
            {
                conn.Open();
                GetTables(conn);
                GetRelations(conn);
                GetConstraints(conn);
                GetStoredProcedures(conn);
                conn.Close();
            }
        }
Пример #2
0
        /// <summary>
        /// Gets a <see cref="OleDbSchema"/> that contains the schema for a
        /// given connection string.
        /// </summary>
        /// <param name="connString">OleDb connection string used to
        /// initialize the new <see cref="OleDbSchema"/>.</param>
        /// <returns>
        /// A new <see cref="OleDbSchema"/> containing the schema for the
        /// given <paramref name="connString"/> or null if the connection
        /// string is invalid.
        /// </returns>
        public static OleDbSchema GetSchema(string connString)
        {
            // trivial test
            connString = OleDbConnString.TranslateConnectionString(connString);
            if (string.IsNullOrEmpty(connString) ||
                connString.IndexOf("Provider=", StringComparison.OrdinalIgnoreCase) < 0)
            {
                return(null);
            }

            // connString looks OK, try getting the schema
            try
            {
                var ds = new OleDbSchema();
                ds.ConnectionString = connString;
                return(ds);
            }
            catch
            {
                return(null);
            }
        }