1
//连接Oracle数据库
2
MIConnection Connection = new MIConnection();
3
try
4
{
5
Connection.Open();
6
TableInfoServer ti = new TableInfoServer("ConnOracle");
7
ti.ConnectString = "SRVR=Test;UID=en;PWD=en";
8
ti.Query = "Select * From Test";
9
ti.Toolkit = ServerToolkit.Oci;
10
ti.CacheSettings.CacheType = CacheOption.Off;
11
12
MapInfo.Data.Table table = Connection.Catalog.OpenTable(ti);
13
if (table != null)
14
{
15
FeatureLayer fl = new FeatureLayer(table);
16
LayerHelper.SetEditable(fl, true);
17
fl.VolatilityHint = MapInfo.Mapping.LayerVolatilityHint.CacheIfPossible;
18
MapInfo.Mapping.Map map = MapInfo.Engine.Session.Current.MapFactory[0];
19
map.Layers.Add(fl);
20
MessageBox.Show("Open Server data successful!");
21
}
22
}
23
catch (SqlException sqlEx)
24
{
25
MessageBox.Show(sqlEx.ToString());
26
}
27
finally
28
{
29
Connection .Close();
30
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30
