locked
How to select from database table with "SHAPE" column? RRS feed

  • Question

  • I need to select data from a table.

    This table has a number of normal columns, like int, varchar, datetime, etc.
    However, it also has a "SHAPE" column, which is something custom and special to GIS.

    My code throws an exception, saying it can't handle this.

    In theory, a SHAPE would just be an array of co-ordinates... so a two-dimensional array of decimals. Perhaps there's some way to convert it to a varchar or string?


    • Edited by CodeSmile Monday, June 13, 2016 7:34 PM
    Monday, June 13, 2016 7:33 PM

Answers

  • Hi CodeSmile,

    If it is a User-Defined Type, you need to define a custom type in .NET Framework to mapping it. For detail information, link below is for your reference.

    Oracle User-Defined Types (UDTs) and .NET Custom Types

    In addition, I suggest you post this question on Oracle Data Provider for .NET official forum for further discussion.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by DotNet Wang Monday, June 20, 2016 9:48 AM
    • Marked as answer by DotNet Wang Monday, June 27, 2016 9:47 AM
    Tuesday, June 14, 2016 2:23 AM

All replies

  • What sort of data source are you querying?

    What C# libraries are you using to query?

    David


    David http://blogs.msdn.com/b/dbrowne/

    Monday, June 13, 2016 7:47 PM
  • Hi David,

    I'm currently using a self-made class I'm calling "GIS" to access the GIS database.
    The data source is Oracle, using Oracle.DataAccess.dll as a project reference.

    I run it like so:

    DataTable dt = GIS.Run("select * from TABLE");

    The Run() function looks like this:

            public static DataTable Run(string str)
            {
                str = str.Replace("@", ":");
    
                OracleCommand com = new OracleCommand(str, con);
                OracleDataAdapter sda = new OracleDataAdapter(com);
                DataTable dt = new DataTable();
                sda.Fill(dt);
    
                return dt;
            }

    And the connection string:

    static OracleConnection con = new OracleConnection("Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = " + hostServer + ")(PORT = 1521)))(CONNECT_DATA =(SID = " + SID + ")    )  );User Id=" + username + ";Password=" + password + ";");

    Monday, June 13, 2016 8:07 PM
  • So what is the "SHAPE" data type.  AFAIK it's not a built-in type in Oracle.

    David


    David http://blogs.msdn.com/b/dbrowne/

    Monday, June 13, 2016 8:36 PM
  • Hi CodeSmile,

    If it is a User-Defined Type, you need to define a custom type in .NET Framework to mapping it. For detail information, link below is for your reference.

    Oracle User-Defined Types (UDTs) and .NET Custom Types

    In addition, I suggest you post this question on Oracle Data Provider for .NET official forum for further discussion.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by DotNet Wang Monday, June 20, 2016 9:48 AM
    • Marked as answer by DotNet Wang Monday, June 27, 2016 9:47 AM
    Tuesday, June 14, 2016 2:23 AM