使用产品:supermap-iobjectsdotnet-10.0.1-18027-76100
操作系统:win10 x64
数据库:mysql
我的需求是往mysql数据源中添加数据集
根据官方的DatasetManage示例,我写了如下代码:
Workspace workspace = null;
DatasourceConnectionInfo info = null;
try
{
Toolkit.SetDtNameAsTableName(true);
var datasetName = "test222";
workspace = new Workspace();
info = new DatasourceConnectionInfo();
Datasource datasource = GetDbDatasource(workspace, info);
Datasets datasets = datasource.Datasets;
if (!datasets.IsAvailableDatasetName(datasetName))
{
datasets.Delete(datasetName);
}
DatasetVectorInfo vectorInfo = new DatasetVectorInfo();
vectorInfo.Name = datasetName;
vectorInfo.Type = DatasetType.Point;
var result = datasets.Create(vectorInfo);
if (result != null)
{
MessageBox.Show("添加数据集成功");
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (info != null)
{
info.Dispose();
}
if (workspace != null)
{
workspace.Dispose();
}
}
已知GetDbDatasource方法获取数据源成功,我可以读取已有数据集
所以,我哪里写错了么?代码也没有反馈、也没有报错,就是result=null,而且数据集添加未成功……