kaspatoo

Read XY Coordinates from CSV and create Point Feature/ insert into GeoDB

Discussion created by kaspatoo on Mar 14, 2011
Latest reply on Mar 28, 2011 by LokionNitrox
Hello,

I'm trying to read coordinates from a CSV File and insert them into my personal geodatabase.
I have created a layer ("Koordinaten") in my geoDB. There I want to add one or more points.

I thought of an insert query but didn find any material.
Now I tried to merge some code-snipplets I found:

public void InsertRows()
        {
            try
            {
                String strMDBFile = @"\\vmware-host\Shared Folders\SharedFolder\GeoData\Detmold\DetmoldDB.mdb";

                Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
                IWorkspaceFactory aoiAccFact = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

                IFeatureWorkspace aoiAccWsp = (IFeatureWorkspace)aoiAccFact.OpenFromFile(strMDBFile, 0);
                IFeatureClass aoiFeatClass = aoiAccWsp.OpenFeatureClass("Koordinaten");

                IFeatureClassWrite aoiFCW = (IFeatureClassWrite)aoiFeatClass;

                IPoint p1 = new PointClass();
                p1.X = 100;
                p1.Y = 100;

                aoiFCW.WriteFeature((IFeature)p1);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace);
            }
        }


Buzt when executing
IFeatureWorkspace aoiAccWsp = (IFeatureWorkspace)aoiAccFact.OpenFromFile(strMDBFile, 0);


I get an error:

Ausnahmemeldung "Beim Aufruf einer COM-Komponente wurde ein HRESULT E_FAIL-Fehler zurückgegeben."
Ausnahmetyp "System.Runtime.InteropServices.COMException"



But the error is not my main-intention I think. Primary I want to know wether I'm on the right way or there is a better one to achieve my aim.

Thanks for any help.

Outcomes