Select to view content in your preferred language

Create SDE database programmatically

2165
7
05-11-2011 12:10 PM
ChrisSeabrooke
Deactivated User
I'm adding support for SDE to an application that currently allows customers to use personal or file geodatabases. If the database doesn't exist, we create it using the ESRI.ArcGIS.Geodatabase.IWorkspaceFactory.Create method.

For a personal geodatabase:
workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();
System.IO.FileInfo fInfo = new System.IO.FileInfo("MyDataBase");
workspaceName = workspaceFactory.Create("c:\\Temp\", fInfo.Name, null, 0);

For a file geodatabase:
workspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass();
workspaceName = workspaceFactory.Create("c:\\Temp\", "MyDataBase", null, 0);

Is there a similar method to create an SDE database? I've found code samples to create a spatial database connection but I have to use ArcCatalog to create the geodatabase in order to use the connection. What we want to do is create the geodatabase using C# code. Has anyone done this?

Using ArcGIS10, SQLServer Express 2008, ArcEditor
0 Kudos
7 Replies
VinceAngelo
Esri Esteemed Contributor
Personal and Workgroup ArcSDE have C# hooks in ArcObjects, but Enterprise ArcSDE
requires the use of 'sdesetup' and 'sdeservice' utilities.   You can wrap them, but the
level of artificial intelligence to handle common troubleshooting would add man-years
to the effort.

- V
0 Kudos
ChrisSeabrooke
Deactivated User
We are using personal and workgroup -- so where do I find information about creating the SDE in C# code? I opened an ESRI incident for this question (927165) -- the resolution on that case entered by support is: "Informed user that it is not possible to create the sde geodatabases, but it is possible to connect to the sde geoedatabase and can access the data and perform operatons on the sde data."
0 Kudos
VinceAngelo
Esri Esteemed Contributor
If Tech Support says the geodatabase creation code is not publicly exposed,
then I believe them.

- V
0 Kudos
CraigGillgrass
Esri Regular Contributor
Chris,

Take a look at the following article:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Creating_geodatabases/0...

It shows how to create geodatabases stored in SQL Server Express.
0 Kudos
ChrisSeabrooke
Deactivated User
Thanks Craig,
That was exactly what I was looking for.

Chris
0 Kudos
GregRieck
Frequent Contributor
Chris,

How did this process turn out? Were you successful?

I'm looking for information on how to programmatically create a database and schema for a MS SQL Server. However, this requires the user to run the ArcGIS MS SQL Server Post Installation. Is that a process you have to do as well for SQL Express?

Does any one have any links or advice on if this is possible? What about work arounds? What if the database was manually created by the user then the schema was created through code via a connection to the new database? What about just creating the database and schema as a personal geodatabase and then programmatically exporting it to xml and importing it into the new manually created database? What about programmatically calling the Post Installation window, trapping for when it sucessfully completes and then programmatically creating the schema in the new database? I'm willing to entertain any workaround. The best solution would be to handle the entire process programmatically or a mix of calling/running the post installation.



MS SQL Server 2008 R2 x64
ArcGIS 10 - ArcEditor
Windows Server 2008 R2 x64
0 Kudos
RussellBrennan
Esri Contributor
GR,

If you are planning to upgrade to 10.1 when it becomes available and you are willing to wait for it; all of the functionality that you are looking for will be available through Python/geoprocessing. You could either use Python scripts directly or you could make geoprocessing calls from your C#/ArcObjects code.
0 Kudos