免费视频|新人指南|投诉删帖|广告合作|地信网APP下载

查看: 1923|回复: 3
收起左侧

技术资料:地图与数据库中有一字段相同,将它们关联起来

[复制链接]

2072

主题

100000万

铜板

363

好友

地信专家组

每一次的分离都是为了下一次的相聚

Rank: 14Rank: 14Rank: 14Rank: 14

积分
17622

精华勋章宣传勋章爱心勋章组织勋章地信元老灌水勋章荣誉会员勋章活跃勋章贡献勋章

发表于 2009-11-15 19:26 | 显示全部楼层 |阅读模式
技术资料:地图与数据库中有一字段相同,将它们关联起来
下列代码实现了类似地理匹配的功能。即TAB与DataBase中有一字段相同,将二者关联起来。(采用ODBC,DAO,ADO三种方式)

Private Sub cmdCustom_Click()
'Add the single layer
Map1.Layers.RemoveAll
Map1.Layers.Add App.Path & "\import.tab"
'make the map look nice for the sample data
Map1.DisplayCoordSys = Map1.NumericCoordSys
Map1.Title.Visible = False
Map1.Bounds = Map1.Layers.Item("import").Bounds
Map1.Zoom = Map1.Zoom * 2
Clickable (True)
End Sub
Private Sub cmdQuit_Click()
End
End Sub

Private Sub Command1_Click()
Dim ds As MapXLib.Dataset
Dim flds As New MapXLib.Fields
'requires reference to: "MapX ODBC Dataset Engine Library"
'and an ODBC DSN named import needs to be linked to import.mdb
Dim parm As New ODBCQueryInfo
parm.SqlQuery = "Select * from table1"
parm.DataSource = "import" 'DSN pointing to Mapstats.mdb
parm.ConnectString = "ODBC;"
' Get the relevant fields that'll come from DB
flds.Add "DB1", "DB1", miAggregationIndividual, miTypeString
flds.Add "DB2", "DB2byODBC", miAggregationIndividual, miTypeString
'Make Dataset
Set ds = Map1.Datasets.Add(miDataSetODBC, parm, "importODBC", "DB1", , "import", flds)
'make the theme
ds.Themes.Add miThemeAuto
Clickable (False)
End Sub

Private Sub Command2_Click()
Dim ds As MapXLib.Dataset
Dim flds As New MapXLib.Fields
'requires reference to: "Microsoft DAO Object Library"
Dim db As Database
Dim rs As Recordset
'open Database and recordset
Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "/import.mdb")
Set rs = db.OpenRecordset("table1")
'define the fields
flds.Add "DB1", "DB1", miAggregationIndividual, miTypeString
flds.Add "DB2", "DB2byDAO", miAggregationIndividual, miTypeString
'add the dataset
Set ds = Map1.Datasets.Add(miDataSetDAO, rs, "importDAO", "DB1", , "import", flds)
'make theme and close out
ds.Themes.Add miThemeAuto
rs.Close
db.Close
Clickable (False)
End Sub

Private Sub Command3_Click()
Dim ds As MapXLib.Dataset
Dim flds As New MapXLib.Fields
'requires reference to Microsoft ActiveX Data Objects Library
Dim rs As New ADODB.Recordset
Dim Conn As New ADODB.Connection
Conn.Open (&quotrovider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & App.Path & "\import.mdb")
rs.CursorLocation = adUseClient
rs.Open "SELECT * FROM table1 ", Conn
'define the fields
flds.Add "DB1", "DB1", miAggregationIndividual, miTypeString
flds.Add "DB2", "DB2byADO", miAggregationIndividual, miTypeString
'add dataset
Set ds = Map1.Datasets.Add(miDataSetADO, rs, "importADO", "DB1", , "import", flds)
'make theme
ds.Themes.Add miThemeAuto
Clickable (False)
End Sub

Private Sub Form_Load()
Clickable (False)
End Sub

Public Sub Clickable(ByVal b As Boolean)
Command1.Enabled = b
Command2.Enabled = b
Command3.Enabled = b
End Sub  
--------------------------------------------------------------------------------

2

主题

4万

铜板

7

好友

钻石会员

Rank: 26Rank: 26Rank: 26Rank: 26Rank: 26Rank: 26Rank: 26

积分
6697
发表于 2021-12-19 14:53 | 显示全部楼层
谢谢分享
回复

使用道具 举报

0

主题

2万

铜板

1

好友

资深会员

Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18

积分
3513
发表于 2022-1-4 09:43 | 显示全部楼层
地图与数据库中有一字段相同
回复 支持 反对

使用道具 举报

0

主题

2638

铜板

0

好友

教授级高工

Rank: 12Rank: 12Rank: 12

积分
1542
发表于 2025-1-8 10:33 | 显示全部楼层
探矿者件可以提高矿体的命中率,减少找矿的成本和难度,主要功能:数据管理、二维制图、三维建模、储量估算、三维立体预测等,有需要免费试用可以联系负责人邓帅15377311476(微信同号),软件针对单位或者企业试用,不面向个人试用
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

在线客服
快速回复 返回顶部 返回列表