Select to view content in your preferred language

Geoprocessing tools in .NET syntax : Syntax to reference an SDE geodatabase

2402
4
05-24-2011 01:52 AM
MichaelBlom
Deactivated User
Hi there,

I'd like to append shapefiles into an SDE geodatabse.  I've tried shp2sde, but I get all kinds of polygon-geometry errors and it fails.  Using the DataManagement append tool seems to work, but I need to implement it in my .net application.  I guess I could use model builder, and try to call the python script from .net, but I'd like to use the DataManagement library in .net.

Problem is, I can't find any documentation for how to reference a SDE geodatabase as the ouput.  Can anyone help, please?

var append = new Append();
append.field_mapping = @"\\server1\Perils\WindStorms\columnmatch.txt";
append.inputs = @"\\server1\Perils\WindStorms\201007N_wind_2010080503.shp";
append.output = "???";
append.schema_type = "NO_TEST";
0 Kudos
4 Replies
StefanOffermann
Deactivated User
You have to build a string for the output following the "catalog location scheme", which can be seen when opening an existing feature class in your SDE. It is very easy to build the string when the location of a sde-connection file is known, eg:

append.output = @"C:\path\Connection to My SDE.sde\sde.username.outputFeatureClass";


I hope you get my example 🙂

When you create a connection to an SDE, the sde connection file is created in the application data folder of the user. When the users name is "john" for example, the sde connection file is located in

C:\Documents and Settings\john\Application Data\ESRI\ArcCatalog\Connection to SDE.sde

depending on your Windows Version, this may vary.

It may require some logic to point to the connection file, when your code has to be kind of generic for all kinds of users, operating systems, database management system (Oracle, MS SQL, Postgres?), etc.

Best regards, Stefan
0 Kudos
MichaelBlom
Deactivated User
Thanks Stefan,

I'll try this code out as soon as I get around my latest issue of not being able to create an instance of the Geoprocessor class... argh.

Update:
Argh, if I had a dime for everytime I was caught out by forgetting this code!!

RuntimeManager.Bind(ProductCode.Desktop);

Mike
0 Kudos
CarlosPiccirillo
Emerging Contributor
Michael,

Did you get this solved? I am stuck in the same spot you were.

Thanks,
Carlos

Hi there,

I'd like to append shapefiles into an SDE geodatabse.  I've tried shp2sde, but I get all kinds of polygon-geometry errors and it fails.  Using the DataManagement append tool seems to work, but I need to implement it in my .net application.  I guess I could use model builder, and try to call the python script from .net, but I'd like to use the DataManagement library in .net.

Problem is, I can't find any documentation for how to reference a SDE geodatabase as the ouput.  Can anyone help, please?

var append = new Append();
append.field_mapping = @"\\server1\Perils\WindStorms\columnmatch.txt";
append.inputs = @"\\server1\Perils\WindStorms\201007N_wind_2010080503.shp";
append.output = "???";
append.schema_type = "NO_TEST";
0 Kudos
MichaelBlom
Deactivated User
No, I didn't find any solution to this. I've moved onto a different project. I will need to come back and look at this within a few months though.

My suggestion would be to try and do as much as you can in python, it doesn't seem like the geoprocessing tools in .net are very well supported.

Mike
0 Kudos