|
|
| GeoCommunity Mailing List |
| |
| Mailing List Archives |
| Subject: | RE: [gislist] ArcObjects - IWorkspace |
| Date: |
09/30/2003 09:10:02 AM |
| From: |
Cody, Skip |
|
|
Try these functions
Private Function OpenSDEWorkspace(ByVal sServer As String, ByVal sInstance As String, ByVal sUser As String, ByVal sPassword As String, Optional ByVal sDatabase As String = "", Optional ByVal sVersion As String = "") As esriCore.IWorkspace On Error GoTo ErrorHandler
' Set devault for version if it is not set If sVersion = "" Then sVersion = "SDE.DEFAULT" End If 'Initialize function incase something goes wrong Set OpenSDEWorkspace = Nothing 'Set up a property set with needed information to connect to a sde database Dim pPropertySet As IPropertySet Set pPropertySet = New PropertySet With pPropertySet .SetProperty "SERVER", sServer .SetProperty "INSTANCE", sInstance .SetProperty "USER", sUser .SetProperty "PASSWORD", sPassword .SetProperty "DATABASE", sDatabase .SetProperty "VERSION", sVersion End With Dim pWorkspaceFactory As IWorkspaceFactory Set pWorkspaceFactory = New SdeWorkspaceFactory Set OpenSDEWorkspace = pWorkspaceFactory.Open(pPropertySet, 0)
End Function
Private Function OpenShapeFileWorkspace(ByVal sDatabase As String) As esriCore.IWorkspace On Error GoTo ErrorHandler
Dim pPropertySet As IPropertySet Set pPropertySet = New PropertySet With pPropertySet .SetProperty "DATABASE", sDatabase End With Dim pWorkspaceFactory As IWorkspaceFactory Set pWorkspaceFactory = New ShapefileWorkspaceFactory Set OpenShapeFileWorkspace = pWorkspaceFactory.Open(pPropertySet, 0)
End Function
Private Function OpenPersonalGeodatabase(ByVal sDatabase As String) As esriCore.IWorkspace On Error GoTo ErrorHandler
Dim pPropertySet As IPropertySet Set pPropertySet = New PropertySet With pPropertySet .SetProperty "DATABASE", sDatabase End With Dim pWorkspaceFactory As IWorkspaceFactory Set pWorkspaceFactory = New AccessWorkspaceFactory Set OpenPersonalGeodatabase = pWorkspaceFactory.Open(pPropertySet, 0) End Function
Cheers,
Skip
-----Original Message----- From: Lyall Perry [mailto:lyall@chariot.net.au] Sent: Tuesday, September 30, 2003 5:14 AM To: GISList (E-mail) Subject: [gislist] ArcObjects - IWorkspace
Calling all ArcObjects gurus...
I am attempting to construct a prototype Spatial Decision Support System for my thesis. I am constructing it in Visual Basic 6.0 and running it in ArcMap 8.2 as a DLL. Part of that system requires that I load a comma-delimited text file into ArcMap as a table. I am, however, having a great deal of trouble opening a workspace to do it. The code falls in a heap with an "Automation Error" on the "Set pWorkspace" statement in the procedure included below. Variable 'sImportDir' is the explicit pathname to the working directory.
Can anyone suggest what I might be doing wrong or recommend another method of doing it? Any advice would be much appreciated.
Regards, Lyall Perry Graduate Student in Spatial Information Science University of Adelaide South Australia
'--------------------------------------------------------------------------- ----------------------- Private Sub TableImport(sImportDir As String, sImportFile As String) Dim pFact As IWorkspaceFactory Dim pWorkspace As IWorkspace Dim pFeatWS As IFeatureWorkspace Dim pTable As ITable Set pFact = New TextFileWorkspaceFactory Set pWorkspace = pFact.OpenFromFile(sImportDir, m_App.hWnd) ' <<<<< Automation Error Set pFeatWS = pWorkspace Set pTable = pFeatWS.OpenTable(sImportFile) 'Add the table Add_Table_TOC pTable End Sub '--------------------------------------------------------------------------- -----------------------
_______________________________________________ gislist mailing list gislist@lists.geocomm.com http://lists.geocomm.com/mailman/listinfo/gislist
_________________________________ This list is brought to you by The GeoCommunity http://www.geocomm.com/
Get Access to the latest GIS & Geospatial Industry RFPs and bids http://www.geobids.com _______________________________________________ gislist mailing list gislist@lists.geocomm.com http://lists.geocomm.com/mailman/listinfo/gislist
_________________________________ This list is brought to you by The GeoCommunity http://www.geocomm.com/
Get Access to the latest GIS & Geospatial Industry RFPs and bids http://www.geobids.com
|
|

Sponsored by:

For information regarding advertising rates Click Here!
|