Connecting to a File Geodatabase

746
2
04-11-2012 10:01 AM
KylaJacobsen
New Contributor
Hi all,

it's been a while since I've tried to do this, and my program keeps giving me and error when I launch the form. I'm using a new computer so I'm not sure if it's me or lack of the right software or what.
I've installed the SDK .Net for ArcObjects to Visual Studio 2008.
I'm creating a form to gather data and populate a file Geodatabase that contains Points, Polygons and tables.
I am currently trying to connect to the database. here is my code:

Private Sub frm_general_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim Dataset As IWorkspace


        Dataset = FileGdb("file_path")

    End Sub
    Public Shared Function FileGdb(ByVal Path As String) As IWorkspace
        Dim factoryType As Type = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory")
        Dim workspaceFactory As IWorkspaceFactory = CType(Activator.CreateInstance(factoryType), IWorkspaceFactory)
        Return workspaceFactory.OpenFromFile(Path, 0)
    End Function
0 Kudos
2 Replies
TravisVal
New Contributor III
Hey,

What error are you encountering?

Did you Initialize the licence?

Travis
0 Kudos
KylaJacobsen
New Contributor
Sorry the late response.
I had not initialized the proper license. Thank you
0 Kudos