chrismeteu

How to convert IWorkspace to SqlClient.SqlConnection??

Discussion created by chrismeteu on Apr 28, 2011
Latest reply on Apr 29, 2011 by jamesfreddyc
Here's the deal. I can't have user input (for reasons I can not explain here). I will have a specific Layers in the TOC that I can obtain a FeatureClass and therefore its Workspace. I need to convert that somehow to SqlClient.SqlConnection so I can run stored procedures from the databases that the FeatureClass is apart of. The following code is the closest I've come to converting the IWorkspace, but it is to an ADODB.Connection and I need to stick with SqlCient.SqlConnection due to conformity requirements in my programming department. Anyone know a way??

' _featureClass is obtained from a specific layer found in the TOC

Dim _workspace As ESRI.ArcGIS.Geodatabase.IWorkspace
_workspace = _featureClass.FeatureDataset.Workspace

Dim _fdoToadoConnection As ESRI.ArcGIS.DataSourcesOleDB.IFDOToADOConnection = New ESRI.ArcGIS.DataSourcesOleDB.FdoAdoConnection

Dim _adoConnection As ADODB.Connection
_adoConnection = CType(_fdoToadoConnection.CreateADOConnection(_workspace), ADODB.Connection)

Outcomes