Select to view content in your preferred language

connect to geodatabase arcobjects

1019
2
Jump to solution
07-15-2020 04:04 AM
NadirHussain
Frequent Contributor

Dear All,

we have geodatabase in 10.5 and sql server 2016.i have to write one web service.before we connect to geodatabase when arcsde application server insatlled.But after 10.3 ESRI obselete ARCSDE server.so in my new enviornment i dont have SDE server installation.below function return worksapce in old envirnment.But SDE finish.I cant connect to geodatabase in new enviornemt.so how to connect to geodatabse without SDE server installation

Thanks.

Below code through exception SDE not running.How to solve this in 10.5 arcobjects SDK my geodatabase is in 2016 sq server.i know sdeserver  not install.But i want to connect to geodattabase without sde server.

private IWorkspace getWorkspace()
{

ESRI.ArcGIS.esriSystem.AoInitialize aoInit = null;
esriLicenseStatus licStatus;
IWorkspace workspace = null;
string status = "";
try
{
Console.WriteLine("Obtaining license");
if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
aoInit = new ESRI.ArcGIS.esriSystem.AoInitialize();
licStatus = aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeStandard);
if (licStatus == esriLicenseStatus.esriLicenseCheckedOut)
{
Console.WriteLine("Ready with license.");
if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);
IPropertySet propertySet = new PropertySet();

propertySet.SetProperty("SERVER", "IP");
propertySet.SetProperty("INSTANCE", "5151");
propertySet.SetProperty("DATABASE", "database");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "user");
propertySet.SetProperty("Authentication_mode", "DBMS");
propertySet.SetProperty("VERSION", "SDE.DEFAULT");
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
workspace = workspaceFactory.Open(propertySet, 0);
if (workspace != null) {
return workspace;
}

}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
status = ex.Message.ToString()+" "+ex.Source;
}
return workspace;
}

0 Kudos
1 Solution

Accepted Solutions
NadirHussain
Frequent Contributor

propertySet.SetProperty("SERVER", "IP");
propertySet.SetProperty("INSTANCE", "sde:sqlServer:ServerName");-----this is the line i change
propertySet.SetProperty("DATABASE", "database");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "user");
propertySet.SetProperty("Authentication_mode", "DBMS");
propertySet.SetProperty("VERSION", "SDE.DEFAULT");

Its working like above settings.

Thanks

View solution in original post

0 Kudos
2 Replies
ModyBuchbinder
Esri Regular Contributor

Hi Nadir

You use direct connect.

The help is not very updated but you use the same method as for workgroup sde database.

Check here: How to connect to a geodatabase—ArcObjects 10.4 Help for Java | ArcGIS for Desktop 

Check the ArcMap connect doc, it is basicaly the same Connect to Microsoft SQL Server from ArcGIS—Help | Documentation 

Have fun

0 Kudos
NadirHussain
Frequent Contributor

propertySet.SetProperty("SERVER", "IP");
propertySet.SetProperty("INSTANCE", "sde:sqlServer:ServerName");-----this is the line i change
propertySet.SetProperty("DATABASE", "database");
propertySet.SetProperty("USER", "user");
propertySet.SetProperty("PASSWORD", "user");
propertySet.SetProperty("Authentication_mode", "DBMS");
propertySet.SetProperty("VERSION", "SDE.DEFAULT");

Its working like above settings.

Thanks

0 Kudos