hello7

ArcSDE connection

Discussion created by hello7 on Mar 9, 2012
Latest reply on Mar 9, 2012 by hello7
Does anyone have a script or can point me to one where I can use c# to connect to a SDE Enterprise SQL Database and then run a test to make sure im connected? like a message box or a simple query on a table where i can see results to be sure i'm connected. I tried the code below but im looking for a script that calls this function to connect and tests test connection or runs a quick query. Kind of like an example of the next step after connection where i can use the tables in arcobjects. Thanks




// For example, server = "Kona".
// Database = "SDE" or "" if Oracle.
// Instance = "5151".
// User = "vtest".
// Password = "go".
// Version = "SDE.DEFAULT".
public IWorkspace VersionedArcSdeWorkspace(string server, string instance,
  string user, string password, string database, string version)
{
  IPropertySet propertySet = new PropertySetClass();
  propertySet.SetProperty("SERVER", server);
  propertySet.SetProperty("INSTANCE", instance);
  propertySet.SetProperty("DATABASE", database);
  propertySet.SetProperty("USER", user);
  propertySet.SetProperty("PASSWORD", password);
  propertySet.SetProperty("VERSION", version);

  IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();
  return workspaceFactory.Open(propertySet, 0);
}

Outcomes