You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

How to connect Geodatabase in 9.2 with VB6   riyaz uddin Oct 21, 2007
Re: How to connect Geodatabase in 9.2 with...   Michael Knight Oct 21, 2007
Re: How to connect Geodatabase in 9.2 with...   Michael Parry Dec 05, 2007
Re: How to connect Geodatabase in 9.2 with...   James MacKay Dec 05, 2007
Re: How to connect Geodatabase in 9.2 with...   Michael Parry Dec 06, 2007
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject How to connect Geodatabase in 9.2 with VB6 
Author riyaz uddin 
Date Oct 21, 2007 
Message I have a VB application which work properly in 9.1 but after we upgrade from 9.1 to 9.2 the application fail to connect database. the error message is
Run-time error'-2147220952(80040228)
Automation error
I add the code and error image for view pls help how to solve this problem how to connect geodatabase
 
 
Dim ppropset As IPropertySet
Dim pWorkspaceFact As IWorkspaceFactory
Dim pWorkspace As IWorkspace
Dim pFeatWorkspace As IFeatureWorkspace
Dim pEnumDataset As IEnumDatasetName
Dim pDataset As IDatasetName

Set ppropset = New PropertySet
ppropset.SetProperty "CONNECTSTRING", "Data source=gisdata;User ID=sde;Password=admingisbgdata"

Set pWorkspaceFact = New OLEDBWorkspaceFactory
Set pWorkspace = pWorkspaceFact.Open(ppropset, 0)
'Error message display after this line'
'Run-time error'-2147220952(80040228)';
'Automation error'

Set pFeatWorkspace = pWorkspace
Set pEnumDataset = pWorkspace.DatasetNames(esriDTTable)
Set pEnumDataset = pWorkspace.DatasetNames(esriDTAny)
Set pDataset = pEnumDataset.Next
 
  error.JPG (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to connect Geodatabase in 9.2 with VB6 
Author Michael Knight 
Date Oct 21, 2007 
Message If this is a standalone application (ie. not running in ArcMap) you must check out a license. See IAoInitialize:

http://edndoc.esri.com/arcobjects/9.2/ComponentHelp/esrisystem/IAoInitialize.htm 
  Michael Knight
GIS Solutions Architect
Contract Land Staff, LLC
Stafford, Texas

http://www.contractlandstaff.com

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to connect Geodatabase in 9.2 with VB6 
Author Michael Parry 
Date Dec 05, 2007 
Message Hello,

I having almost exactly the same problem only that I'm trying to open a local pGDB ("C:\Temp\MypGDB.mdb") using a propertyset with a "DATABASE" property set to the aforementioned path of the Access database. My code fails at the same place.

The odd thing is that my code (very similar) works in VBA but won't in VB6 project with all of the appropriate references set.

Did you ever get an answer to this that was helpful? 
  Michael Parry
GIS Specialist
AAFC 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to connect Geodatabase in 9.2 with VB6 
Author James MacKay 
Date Dec 05, 2007 
Message Michael,

The IAoInitialize interface mentioned above is likely the issue with your code. In standalone applications you need to call its Initialize method before you can connect to a workspace (or do a lot of other things, for that matter), whereas in VBA it isn't required. I've attached a really quick example of how to use this interface. 
 
Dim pAoInitialize As IAoInitialize
Dim eLicenseStatus As esriLicenseStatus
Set pAoInitialize = New AoInitialize
eLicenseStatus = pAoInitialize.Initialize(esriLicenseProductCodeArcInfo)
If eLicenseStatus <> esriLicenseCheckedOut Then
  MsgBox "License init failure..."
  End
End If

' All of your code goes here

' When the application shuts down...
pAoInitialize.Shutdown
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: How to connect Geodatabase in 9.2 with VB6 
Author Michael Parry 
Date Dec 06, 2007 
Message Yes indeed.

I inherited a simple VB6 project (not realizing it was, in fact, a Standard EXE project) and it was failing. My issue went a little further in that the code I was trying to execute was housed in an external custom library (which is a DLL) that we use to simplify our coding practices and make our code a little more distributable. I turns out there was a referencing bug in the custom DLL and also I failed to realize that I was trying to debug an EXE and not a DLL.

A comedy of errors, if you will.

I used your example (actually the example code from IAoInitialize Interface on EDN which is pretty much the same) and indeed it worked like a charm.

My apologies, I should've had more faith!

Thanks much! 
  Michael Parry
GIS Specialist
AAFC