Пример #1
0
        public override DBObjectIdentifier GetIdentifier(Cell location)
        {
            DataRow row = _tblViewer.DataTable.Rows[location.Row];

            SqlSvrIdentifier id = new SqlSvrIdentifier();

            id.Context  = _server.DBMSContext;
            id.Type     = DBObjectEnum.Table;
            id.Name     = row["TABLE_NAME"].ToString();
            id.Database = row["TABLE_CATALOG"].ToString();
            id.Owner    = row["TABLE_SCHEMA"].ToString();
            id.SubType  = row["TABLE_TYPE"].ToString();

            return(id);
        }
Пример #2
0
        public override DataTable Export(Cell location)
        {
            //SqlConnection conn = (SqlConnection)_server.OpenNewConnection();
            //conn.ChangeDatabase(_database);

            //TableSchema ts = new TableSchema(conn, GetIdentifier(location).FullName);
            //TableAdapterContext ctx = new TableAdapterContext(ts, conn);
            //TableAdapterEditor adapter = new TableAdapterEditor(ctx);
            //adapter.Fill();
            //return adapter.DataTable;

            DataTable        tbl = null;
            SqlSvrIdentifier id  = (SqlSvrIdentifier)GetIdentifier(location);

            //((SqlSvrInstance)_server).ChangeDatabase(_database);
            _server.Execute(string.Format("SELECT * FROM {0}", id.FullName), out tbl);
            tbl.TableName = id.Name;
            return(tbl);
        }
Пример #3
0
        /// <summary>
        /// Warning: it's caller's responsibility to change the initial catalog (e.g., database)
        ///   before querying table names
        /// </summary>
        public static List <DBObjectIdentifier> GetTableList(DbConnection conn, string owner)
        {
            // TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE ['BASE TABLE' or 'VIEW']
            string[] restrictions = new string[] { null, owner, null, null };

            DataTable         dt   = conn.GetSchema(TableCollection, restrictions);
            DataRowCollection rows = dt.Rows;
            int rowCount           = rows.Count;

            List <DBObjectIdentifier> names = new List <DBObjectIdentifier>(rowCount);

            for (int i = 0; i < rowCount; i++)
            {
                SqlSvrIdentifier obj = new SqlSvrIdentifier();
                obj.Type     = DBObjectEnum.Table;
                obj.Name     = rows[i]["TABLE_NAME"].ToString();
                obj.Database = rows[i]["TABLE_CATALOG"].ToString();
                obj.Owner    = rows[i]["TABLE_SCHEMA"].ToString();
                obj.SubType  = rows[i]["TABLE_TYPE"].ToString();
                names.Add(obj);
            }

            return(names);
        }