惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
P
Privacy International News Feed
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
Scott Helme
Scott Helme
人人都是产品经理
人人都是产品经理
G
GRAHAM CLULEY
O
OpenAI News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
PCI Perspectives
PCI Perspectives
GbyAI
GbyAI
宝玉的分享
宝玉的分享
Y
Y Combinator Blog
T
Troy Hunt's Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
腾讯CDC
C
Check Point Blog
Spread Privacy
Spread Privacy
L
LINUX DO - 最新话题
Recent Announcements
Recent Announcements
大猫的无限游戏
大猫的无限游戏
P
Palo Alto Networks Blog
Hacker News: Ask HN
Hacker News: Ask HN
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Hacker News
The Hacker News
H
Hacker News: Front Page
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
T
Tor Project blog
Martin Fowler
Martin Fowler
博客园 - 叶小钗
罗磊的独立博客
C
Cyber Attacks, Cyber Crime and Cyber Security
H
Heimdal Security Blog
V
Vulnerabilities – Threatpost
Simon Willison's Weblog
Simon Willison's Weblog
Latest news
Latest news
WordPress大学
WordPress大学
G
Google Developers Blog
N
Netflix TechBlog - Medium
S
Security Affairs
S
Secure Thoughts
Know Your Adversary
Know Your Adversary

博客园 - RayG

How to get data from Oracle DB in silverlight via WCF ? [Ray]How to use CString to create a font family - RayG [Copied] 80 VC++ tips [Copied]The GDI Coordinate Systems My Cheating Death solution in VC++ 3 given points, get the angle between two lines 计算几何常用算法(转) Trouble shooting about installation of ArcSDE 9.2 File type transform between ArcGIS and other major type - RayG [Tips] How to converting a Coverage to a Shapefile ? - RayG [Tips] How to Add New field into Shapefile attribute table in ArcGIS ? 子非鱼,安知鱼之乐? [GuanRui] My program implement on Symbian S60 (#1: File IO) - RayG My XNA HitBee small game [GuanRui]How to open Path browse dialog in VBA of ArcGIS Desktop ? [Ray] My GPS (卫星定位接收器) tracker program on Symbian OS Binary Tree ANSI C Implement (2) - RayG Binary Tree ANSI C Implement (1) Graph & Topology & Shortest path
trouble shoot about using BindLayer in MapX with C# [原创]
RayG · 2008-11-01 · via 博客园 - RayG

If you have problem about using BindLayer in MapX with C#, check this out. it may help.  

My Enviroment:Microsoft Visual Studio.NET 2005 (C#)  + Mapinfo MapX 5.02

Keywords: BindLayer ,DataSet,ADO,MapX,C#

Let's cut the bullshit, If you want to follow the VB6 sample to add a new bindlayer into your application, 

congrats, you will make most of your time waste. the .NET make things different. the old good time

passed away and never back again. 

Step 1: you have to add 2 COM reference into your application : ADODB also named Microsoft ActiveX Data Object 2.8

      MapX 5.0,why ADODB, cause the fucking .NET dataset will not work with MapX.

Setp 2: If you want to set you bindlayer style to miBindLayerTypeXY ,you need modify you database firstly, for example, you have to add new primary key columen into you database named like "MYID" in this sample . if you dont do so, there will be an error like "NOT FOUND GeoField or BindLayer".i bet you wont like that. 

Step 3: Copy these code into your program.you may change a little bit to fit your request.

Done! 

========================================================================

private string m_strConnString; 

private ADODB.Connection m_cnn; 

private ADODB.Recordset m_rds;

private ADODB.Recordset RetriveDataFromDB(string pConnString)

{

         m_strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Fart\\DB\\TestDB.mdb";

         m_bndlyrName = "MyBindlayer"; //Set your bindlayer name here

       m_cnn = new ADODB.Connection();

         m_rds = new ADODB.Recordset();

         m_cnn.Open(m_strConnString, null, null, -1);

         m_rds.ActiveConnection = m_cnn;

         m_rds.Open("SELECT MYID, Longitude_X,Latitude_Y FROM GUANRUI_TEST_TBL", m_cnn, ADODB.CursorTypeEnum.adOpenStatic, 

                    ADODB.LockTypeEnum.adLockOptimistic, 1);

         return m_rds;

 }

private void DoBindLayer(ADODB.Recordset pDs)

{

            MapXLib.BindLayer BindLyr;
            MapXLib.Dataset miDS;
            MapXLib.FieldsClass flds;

            miDS = null;
            flds = new MapXLib.FieldsClass();
            BindLyr = new MapXLib.BindLayer();

            flds.Add("MYID", "MYID", MapXLib.AggregationFunctionConstants.miAggregationIndividual, 
                        MapXLib.FieldTypeConstants.miTypeNumeric);
            flds.Add("Longitude_X", "Longitude_X", MapXLib.AggregationFunctionConstants.miAggregationIndividual, 
                        MapXLib.FieldTypeConstants.miTypeNumeric);
            flds.Add("Latitude_Y", "Latitude_Y", MapXLib.AggregationFunctionConstants.miAggregationIndividual, 
                        MapXLib.FieldTypeConstants.miTypeNumeric);
            BindLyr.LayerType = MapXLib.BindLayerTypeConstants.miBindLayerTypeXY;
            BindLyr.RefColumn1 = "Longitude_X";
            BindLyr.RefColumn2 = "Latitude_Y";
            BindLyr.LayerName = m_bndlyrName;
            //BindLyr.FileSpec = Application.StartupPath+ "\\DB\\Test.tab";
            //BindLyr.OverwriteFile = true;
            miDS = axMap1.DataSets.Add(MapXLib.DatasetTypeConstants.miDataSetADO, pDs, BindLyr.LayerName,
                "MYID", System.Reflection.Missing.Value, BindLyr, flds, false);

}