Beispiel #1
0
        /// <summary>
        /// 从数据库中获取数据表记录
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="whereClause"></param>
        /// <returns></returns>
        public static ITable queryTable(string tableName, string whereClause)
        {
            ISqlWorkspace ws = ArcgisService.openBdcWorkspace() as ISqlWorkspace;

            string            query = "select * from " + tableName + " where 1=1 and " + whereClause;
            IQueryDescription q     = ws.GetQueryDescription(query);

            q.OIDFields = "fId";
            string qName = "";

            ws.CheckDatasetName(tableName, q, out qName);
            if (ws.OpenQueryCursor(query).NextRow() == null)
            {
                return(null);
            }
            ITable table = ws.OpenQueryClass(qName, q);

            return(table);
        }
Beispiel #2
0
        public IFeatureLayer getDcxmLayer(int dcxmId, string tableName)
        {
            ISqlWorkspace ws = ArcgisService.openBdcWorkspace() as ISqlWorkspace;

            string            query = "select * from " + tableName + " where QJDCXM_ID=" + dcxmId;
            IQueryDescription q     = ws.GetQueryDescription(query);

            q.OIDFields    = "fId";
            q.GeometryType = esriGeometryType.esriGeometryPolygon;
            string qName = "";

            ws.CheckDatasetName(tableName, q, out qName);
            ITable table = ws.OpenQueryClass(qName, q);

            IFeatureLayer layer = new FeatureLayer();

            layer.FeatureClass = table as IFeatureClass;
            return(layer);
        }