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

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects Visual Basic for Application (VBA) forum

Automation Error -2147220973   Jeff LeNay Mar 02, 2005
Re: Automation Error -2147220973   Matt Crowder Mar 02, 2005
Re: Automation Error -2147220973   Jeff LeNay Mar 03, 2005
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Automation Error -2147220973 
Author Jeff LeNay 
Date Mar 02, 2005 
Message Hi all.

In the code attached I'm trying to create a personal geodatabase. This code works great in XP, but when I test it on a Windows 2000 machine i get and automation error -2147220973. The odd thing is that it works the first time around and then gives me the error the second time around.

I've searched the forums and some people say its a duplicate database error or the path and filename is being entered wrong but I always enter a different filename.

In the code the variable thePath would be something like "C:\temp" and the variable theFile would be something like "test.mdb"

I've tried adding a backslash "\" between the path and the file name but that didn't seem to work.

Can anyone help me out with this?

Thanks,

Jeff 
 
Private Sub CreateDatabase(theFile As String, pWorkspace As IWorkspace, thePath As String)
  ' Create a workspace factory
  Dim pWorkspaceFactory As IWorkspaceFactory
  Set pWorkspaceFactory = New AccessWorkspaceFactory
  
  ' Now create the database
  Dim pProperty As IPropertySet
  Set pProperty = New PropertySet
  
  Dim pWorkspaceName As IName
  On Error GoTo Duplicate
  
  Set pWorkspaceName = pWorkspaceFactory.Create(thePath, theFile, pProperty, 0)
  
  Set pWorkspace = pWorkspaceName.Open
  
  Exit Sub
Duplicate:
 MsgBox Err.Description & "      " & Err.Number
 ' MsgBox "Database already exists.", vbExclamation + vbOKOnly, "Duplicate Database"
  Err.Clear
End Sub
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Automation Error -2147220973 
Author Matt Crowder 
Date Mar 02, 2005 
Message I am not seeing any problem. Can you please confirm it's not some other problem by running the attached code? Also, what version of ArcGIS are you running? 
 
Public Sub test2times()
  Dim pW1 As IWorkspace
  Dim pW2 As IWorkspace  

  CreateDatabase "db1", pW1, "C:\Temp"
  CreateDatabase "db2", pW2, "C:\Temp"  

  Debug.Print pW1.PathName
  Debug.Print pW2.PathName
End Sub

Private Sub CreateDatabase(theFile As String, pWorkspace As IWorkspace, thePath As String)
  ' Create a workspace factory
  Dim pWorkspaceFactory As IWorkspaceFactory

  Set pWorkspaceFactory = New AccessWorkspaceFactory

  ' Now create the database
  Dim pProperty As IPropertySet
  Set pProperty = New PropertySet  

  Dim pWorkspaceName As IName
  On Error GoTo Duplicate  

  Set pWorkspaceName = pWorkspaceFactory.Create(thePath, theFile, pProperty, 0)

  Set pWorkspace = pWorkspaceName.Open

  Exit Sub
Duplicate:
 MsgBox Err.Description & "      " & Err.Number
 ' MsgBox "Database already exists.", vbExclamation + vbOKOnly, "Duplicate Database"
  Err.Clear
End Sub
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Automation Error -2147220973 
Author Jeff LeNay 
Date Mar 03, 2005 
Message Hi Matt. Thanks for replying.

I'm running ArcMap 8.3 and developing in VB6 on an XP machine.

I tried your code in VBScript and as a .dll on XP and Windows 2000 and it works fine which leaves me even more baffled. I have checked and doubl-checked the strings being passed and they are always correct.

In my code I am retrieving the filename and path using a MS Common Dialog Control 6.0 (SP3). Is there anything to your knowledge about this ocx and Windows 2000 that is not compatable with ArcMap?

Thanks,

Jeff