static int Main(string[] args) { string mdb = "", dataset = ""; bool delExisting = true; for (int i = 0; i < args.Length - 1; i++) { if (args[i] == "-mdb") { mdb = args[++i]; } if (args[i] == "-ds") { dataset = args[++i]; } else if (args[i] == "-delexisting") { try { delExisting = Convert.ToBoolean(args[++i]); } catch { } } } if (mdb == "" || dataset == "") { Console.WriteLine("USAGE:"); Console.WriteLine("gView.Cmd.CreateAccessFDBDataset -mdb <Filename> -ds <Datasetname>"); Console.WriteLine(" [-delexisting <true|false>]"); return(1); } try { AccessFDB fdb = new AccessFDB(); if (!fdb.Open(mdb)) { Console.WriteLine("\n\nERROR: " + fdb.lastErrorMsg); return(1); } //SpatialReference sRef = new SpatialReference(); if (fdb.CreateDataset(dataset, null) < 1) { Console.WriteLine("\n\nERROR: " + fdb.lastErrorMsg); fdb.Dispose(); return(1); } fdb.Dispose(); Console.WriteLine(mdb + ": Dataset " + dataset + " created..."); return(0); } catch (Exception ex) { Console.WriteLine("\n\nERROR: " + ex.Message); return(1); } }
public IExplorerObject CreateExplorerObject(IExplorerObject parentExObject) { if (!CanCreate(parentExObject)) { return(null); } FormNewDataset dlg = new FormNewDataset(); dlg.IndexTypeIsEditable = false; if (dlg.ShowDialog() != DialogResult.OK) { return(null); } AccessFDB fdb = new AccessFDB(); fdb.Open(parentExObject.FullName); int dsID = -1; string datasetName = dlg.DatasetName; switch (dlg.DatasetType) { case FormNewDataset.datasetType.FeatureDataset: dsID = fdb.CreateDataset(datasetName, dlg.SpatialReferene); break; case FormNewDataset.datasetType.ImageDataset: dsID = fdb.CreateImageDataset(datasetName, dlg.SpatialReferene, null, dlg.ImageSpace, dlg.AdditionalFields); datasetName = "#" + datasetName; break; } if (dsID == -1) { MessageBox.Show(fdb.lastErrorMsg, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } return(new AccessFDBDatasetExplorerObject(parentExObject, parentExObject.FullName, datasetName)); }