Select to view content in your preferred language

Application crashes when executing OleDbDataReader on Esri SDE Oracle database

842
6
06-17-2010 05:45 AM
VladiH_
Emerging Contributor
Hi, I am using this method to open the geodatabase:

        public OleDbConnection ArcSdeConnectionWithString(String server, String userId, String password, String geometry, String instance, String version)
        {
            String blankSdeConnectionString = "Provider=ESRI.GeoDB.OleDB.1;Location={0};Data Source=ekndkonv;User Id={1};Password={2};" + "Extended Properties=workspacetype=esriCore.SdeWorkspaceFactory.1;Geometry={3};Instance={4};Version={5}";
            String connectionString = String.Format(blankSdeConnectionString, server, userId, password, geometry, instance, version);
            OleDbConnection sdeConn = new OleDbConnection();
            sdeConn.ConnectionString = connectionString;
            return sdeConn;
        }

And then in a separate method:
         OleDbConnection conn = eoledb.ArcSdeConnectionWithString("ip address of my server", "userid", "password", "WKB", "5121", "SDE.DEFAULT");
            conn.Open();

OleDbCommand cmd = new OleDbCommand("SELECT OBJECTID FROM tableName", conn);
            OleDbDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                Console.WriteLine(reader["OBJECTID"].ToString());
            }
            conn.Close();

Connection opens, so the connection string should be OK, but once the execution reaches the line where " cmd.ExecuteReader();" is called, it crashes down with the following message:
"Windows has triggered a breakpoint in MyApp.exe.
This may be due to a corruption of the heap, which indicates a bug in MyApp.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while MyApp.exe has focus.
The output window may have more diagnostic information."

The query seems ok, very simple, I examined it with OracleConnection and OracleCommand, it ran perfectly well, but I want to use "ESRI.GeoDB.OleDB.1" as Provider instead of Oracle provider, because it supports versioning of the SDE database- as in the method above. But this approach does not work for me. I would like to execute a bit more complicated queries against Oracle SDE DB in the future that include "join", "groupe by" or "having" statements, but for some reason I cannot run a simple query with "ESRI.GeoDB.OleDB.1" provider.  Can anybody tell me why? What am I doing wrong?

Your help is very appreciated!
0 Kudos
6 Replies
VladiH_
Emerging Contributor
One additional information: The Language used is C# 3.5.
0 Kudos
LanceShipman
Esri Regular Contributor
Have you checked out a license? The ESRI Ole DB provider requires the a license be checked out.
0 Kudos
VladiH_
Emerging Contributor
Hi, yes, this is my method for Initializing license:

       public void InitializeLicense()
        {
            ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();
            ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcInfo);
        }

It works for anything else in my code...  does OleDbConnection require something else?

Thanx for your reply!
0 Kudos
LanceShipman
Esri Regular Contributor
Hi, yes, this is my method for Initializing license:

       public void InitializeLicense()
        {
            ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();
            ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcInfo);
        }

It works for anything else in my code...  does OleDbConnection require something else?

Thanx for your reply!


Looks correct. In your connection string you have "esriCore.SdeWorkspaceFact ory". This should be "esriCore.SdeWorkspaceFactory".
0 Kudos
VladiH_
Emerging Contributor
It is "SdeWorkspaceFactory" in the original code, the space you pointed out was caused just by formatting of the webpage component (textbox), where I copied the original text of my code.
0 Kudos
VladiH_
Emerging Contributor
Dear lshipman, as the space you were talking about is & was not present in my original code (was just caused by the textbox in this webpage), I still have got the same problem I described.

Does anyone have got any ideas how to solve this?

Thank you for your reply!
0 Kudos