Пример #1
0
        private void CreateDataset_Click(object sender, RoutedEventArgs e)
        {
            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();
                }
            }
        }