What is the proper way to declare an SDE workspace for GP tools in c# .net?
I am using ArcGIS 10.1 SDE (MS SQL) on server 2008, i want to write code so that everynight the server will fire a program and compress one of my SDE databases. I thought i could do this in c# using the compress tool in the data management namespace but have run into a snag.
I am told my workspace is invalid. Esri help docs don't do me much good, as they just show generic help (http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/#/in_workspace_Property/005400000202000000/) and my internet search has lead to bubkis. Can anyone tell me how to define a SDE workspace in 10.1 in net?
Right now i am using @"Database Connections\CME.sde" Here is the error:
Executing: Compress "Database Connections\CME.sde" Start Time: Fri Oct 12 13:40:47 2012 Failed to execute. Parameters are not valid. ERROR 000837: The workspace is not the correct workspace type. Failed to execute (Compress).
what should i be typing for the in_workspace?
private void button1_Click(object sender, EventArgs e)
{
Compress Compressor = new Compress();
object in_workspace = @"Database Connections\CME.sde";
Compressor.in_workspace = in_workspace;
Geoprocessor GP = new Geoprocessor();
RunTool(GP, Compressor, null);
}
private static void RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC)
{
// Set the overwrite output option to true
geoprocessor.OverwriteOutput = true;
// Execute the tool
try
{
geoprocessor.Execute(process, null);
ReturnMessages(geoprocessor);
}
catch (Exception err)
{
MessageBox.Show(err.Message);
ReturnMessages(geoprocessor);
}
}
private static void ReturnMessages(Geoprocessor gp)
{
if (gp.MessageCount > 0)
{
for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
{
Console.WriteLine(gp.GetMessage(Count));
}
}
}
}
